github.com/amlun/go-oauth2-server@v1.0.1/oauth/routes.go (about)

     1  package oauth
     2  
     3  import (
     4  	"github.com/RichardKnop/go-oauth2-server/util/routes"
     5  	"github.com/gorilla/mux"
     6  )
     7  
     8  const (
     9  	tokensResource     = "tokens"
    10  	tokensPath         = "/" + tokensResource
    11  	introspectResource = "introspect"
    12  	introspectPath     = "/" + introspectResource
    13  )
    14  
    15  // RegisterRoutes registers route handlers for the oauth service
    16  func (s *Service) RegisterRoutes(router *mux.Router, prefix string) {
    17  	subRouter := router.PathPrefix(prefix).Subrouter()
    18  	routes.AddRoutes(s.GetRoutes(), subRouter)
    19  }
    20  
    21  // GetRoutes returns []routes.Route slice for the oauth service
    22  func (s *Service) GetRoutes() []routes.Route {
    23  	return []routes.Route{
    24  		{
    25  			Name:        "oauth_tokens",
    26  			Method:      "POST",
    27  			Pattern:     tokensPath,
    28  			HandlerFunc: s.tokensHandler,
    29  		},
    30  		{
    31  			Name:        "oauth_introspect",
    32  			Method:      "POST",
    33  			Pattern:     introspectPath,
    34  			HandlerFunc: s.introspectHandler,
    35  		},
    36  	}
    37  }