package server import ( "fmt" "local/oauth2/oauth2server/config" "local/router" "net/http" ) func (s *Server) Routes() error { endpoints := []struct { skip bool path string handler http.HandlerFunc }{ { path: fmt.Sprintf("authorize/%s", router.Wildcard), handler: s.authorize, }, { path: fmt.Sprintf("verify/%s", router.Wildcard), handler: s.verify, }, { path: fmt.Sprintf("users/log/%s", router.Wildcard), handler: s.usersLog, }, { skip: !config.UserRegistration, path: fmt.Sprintf("users/register/%s", router.Wildcard), handler: s.usersRegister, }, { skip: !config.UserRegistration, path: fmt.Sprintf("users/submit/%s", router.Wildcard), handler: s.usersSubmit, }, } for _, endpoint := range endpoints { if endpoint.skip { continue } if err := s.Add(endpoint.path, endpoint.handler); err != nil { return err } } return nil }