github.com/wanliu/go-oauth2-server@v0.0.0-20180817021415-f928fa1580df/oauth/routes.go (about)

     1  package oauth
     2  
     3  import (
     4  	"github.com/gorilla/mux"
     5  	"github.com/wanliu/go-oauth2-server/util/routes"
     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  			Name:        "userinfo",
    38  			Method:      "GET",
    39  			Pattern:     "/userinfo",
    40  			HandlerFunc: s.userinfoHandler,
    41  		},
    42  	}
    43  }