go-http-auth icon indicating copy to clipboard operation
go-http-auth copied to clipboard

Imlement http.Handler interface

Open stokito opened this issue 3 years ago • 0 comments

It good that we may set basic auth on per-endpoint level

http.HandleFunc("/user/", authenticator.Wrap(handleUser))
http.HandleFunc("/book/", authenticator.Wrap(handleBook))

But for most cases it would be better to have some global "interceptor" for all endpoints. And looks like the most simple way is to make a delegating Handler and use it with SericeMux. Here I created a basic sample: https://gist.github.com/stokito/24b3e6efb3e1e9357c7d964a7df2c18c

Can you add such AuthHandler into the library?

stokito avatar Nov 21 '21 22:11 stokito