2020-09-30 06:35:07 +00:00
|
|
|
package httpserver
|
|
|
|
|
2020-09-30 07:48:56 +00:00
|
|
|
import (
|
|
|
|
"github.com/gorilla/mux"
|
|
|
|
)
|
2020-09-30 06:35:07 +00:00
|
|
|
|
|
|
|
func (s *server) routes() {
|
|
|
|
s.router = mux.NewRouter()
|
2020-09-30 07:48:56 +00:00
|
|
|
|
2020-09-30 08:12:59 +00:00
|
|
|
authMiddleware := s.AuthMiddleware()
|
|
|
|
|
2020-09-30 06:35:07 +00:00
|
|
|
s.router.HandleFunc("/", s.handleIndex()).Methods("GET")
|
2020-09-30 08:12:59 +00:00
|
|
|
|
|
|
|
// if you want to use a general purpose middleware (http.Handler
|
|
|
|
// wrapper) on a specific HandleFunc route, you need to take the
|
|
|
|
// .ServeHTTP of the http.Handler to get a HandleFunc, viz:
|
|
|
|
s.router.HandleFunc("/login", authMiddleware(s.handleLogin()).ServeHTTP).Methods("GET")
|
|
|
|
|
2020-09-30 06:35:07 +00:00
|
|
|
s.router.HandleFunc("/.well-known/healthcheck.json", s.handleHealthCheck()).Methods("GET")
|
2020-09-30 07:48:56 +00:00
|
|
|
|
|
|
|
s.router.Use(s.LoggingMiddleware())
|
2020-09-30 06:35:07 +00:00
|
|
|
}
|