-
-
Notifications
You must be signed in to change notification settings - Fork 533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: Request handler API #290
Comments
I think that the features that you list could be enough to create custom libraries. |
@marcosvega91, yeap, we've got the WebSocket feature request opened here #156. |
With #319 the request matching API is now publicly exposed as |
We may have to expose a few internal functions (i.e. default loggers) for a more comfortable creation of custom handlers, but I find the current state of the request handler API sufficient for most purposes: msw/src/utils/handlers/requestHandler.ts Lines 63 to 122 in 327b384
I will document this in the recipe and close this. |
What
Need to refine an existing Request handler API to be publicly usable.
The Request handler API is already designed with the support of creating custom request handlers for about any purpose (support of a specific communication convention, embed application's logic into handlers, etc.). However, if you take a look at the implementation example on the library's side, it uses quite a few internal functions, which may be useful to expose in the public API:
getCleanUrl
isStringEqual
match
log()
function.Instead of proxying single functions from internal/external packages, MSW should expose a high-level API that can help developers build their own request handlers. Such high-level API may include:
matchesUrl()
, that would clean and match two given URLs just as MSW does for REST API.log()
, a ready-to-use logging function (call signature preserved).Motivation
Current API
Type declaration
msw/src/handlers/requestHandler.ts
Lines 54 to 106 in 6001b79
Implementation example
msw/src/rest.ts
Lines 50 to 147 in 6001b79
The text was updated successfully, but these errors were encountered: