package main import ( "expvar" "net/http" "github.com/julienschmidt/httprouter" ) func (app *application) routes() http.Handler { router := httprouter.New() router.NotFound = http.HandlerFunc(app.notFoundResponse) router.MethodNotAllowed = http.HandlerFunc(app.methodNotAllowResponse) router.HandlerFunc(http.MethodGet, "/v1/healthcheck", app.healthcheckHandler) // 授权 router.HandlerFunc(http.MethodGet, "/v1/login", app.loginHandler) router.HandlerFunc(http.MethodGet, "/v1/oauth2", app.oauth2Handler) router.HandlerFunc(http.MethodPost, "/v1/refresh-token", app.refreshTokenHandler) router.Handler(http.MethodGet, "/debug/vars", expvar.Handler()) return app.metrics( app.recoverPanic( app.enableCORS( app.rateLimit( app.authenticate(router), ), ), ), ) }