Deviopath › Go

Auth Middleware

Hard · HTTP

A handler is func(path, token string) (status int, body string). Wrap it so that if token is empty the wrapper returns 401, "unauthorized" without calling the inner handler. Otherwise call through.

Write WithAuth(next). RunAuth(token, path) is already written with an inner handler that returns 200, path.

Next: Method Router