nodejs / undici

An HTTP/1.1 client, written from scratch for Node.js
https://nodejs.github.io/undici
MIT License
6.05k stars 530 forks source link

Improve docs on Interceptors #3218

Open tastypackets opened 4 months ago

tastypackets commented 4 months ago

This would solve...

Currently docs have limited information for interceptors and it's not easy to discover them, Dispatcher.compose() is probably the best documentation in the docs site and it lacks an example or information on the handler callbacks. There is what looks like an outdated DispatchInterceptor markdown file in the docs, which is no longer part of the docs sidebar or links. I think this is left over from the interceptors param on Client that's deprecated?

The implementation should look like...

Add more detailed documentation on interceptors, ideally it should be easier to discover and include handlers examples and or documentation on the handlers.

One option might be to link the handlers documented above on the dispatch method, since they are well documented there. I think right now the issue is more so discovery of interceptors and handlers. How can we better surface the information in the docs. 🤔

I have also considered...

Additional context

If this issue is still open for a bit I can try and open a PR to help expand the docs on interceptors, but a little busy this week and wanted to open the issue to make sure it's tracked. 🙂

metcoder95 commented 4 months ago

You are right, the DispatchInterceptro is a concept that will be dropped in next major, so currently its usage is not recommended but Dispatcher.compose instead.

Will be nice to have an enhancement on the documentation, we are aware we need to support in there.

I believe we can start with an example of an interceptor with custom handlers and link to the handler's documentation, but open to suggestions 🙂

A PR is always welcomed