Documentation ¶
Index ¶
- type HTTPMethod
- type Option
- type Options
- type Route
- type Server
- func (s *Server) CallbackHandler(w http.ResponseWriter, req *http.Request)
- func (s *Server) CredentialHandler(w http.ResponseWriter, req *http.Request)
- func (s *Server) HealthHandler(w http.ResponseWriter, req *http.Request)
- func (s *Server) LoginHandler(w http.ResponseWriter, req *http.Request)
- func (s *Server) RegisterRoute(r *Route)
- func (s *Server) RegisterRoutes(rs ...*Route)
- func (s *Server) Run() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPMethod ¶
type HTTPMethod string
HTTPMethod wraps all HTTP methods valid for a route
const ( GET HTTPMethod = "GET" HEAD HTTPMethod = "HEAD" POST HTTPMethod = "POST" PUT HTTPMethod = "PUT" DELETE HTTPMethod = "DELETE" CONNECT HTTPMethod = "CONNECT" OPTIONS HTTPMethod = "OPTIONS" TRACE HTTPMethod = "TRACE" PATCH HTTPMethod = "PATCH" )
func (HTTPMethod) String ¶
func (h HTTPMethod) String() string
String converts HTTP method to string
type Option ¶
type Option func(o *Options)
Option is a functional way of setting options for the server
func WithDirectory ¶
WithDirectory sets the Directory Service
func WithLogger ¶
WithLogger sets a logger on the Options struct
func WithRouter ¶
WithRouter sets a router on the Options struct
type Options ¶
type Options struct { Router *mux.Router Logger *zap.Logger Port int OAuth oauth.Service Directory directory.Service Role role.Service }
Options contain all server options
type Route ¶
type Route struct { Path string HandlerFunc func(http.ResponseWriter, *http.Request) Method HTTPMethod // Accepts pairs of query values as a slice of strings Queries []string }
Route wraps a route
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server runs a HTTP server with some helpers
func (*Server) CallbackHandler ¶
func (s *Server) CallbackHandler(w http.ResponseWriter, req *http.Request)
CallbackHandler handles the OAuth callback https://developers.google.com/identity/protocols/OAuth2WebServer
func (*Server) CredentialHandler ¶
func (s *Server) CredentialHandler(w http.ResponseWriter, req *http.Request)
CredentialHandler takes in a client access token, validates it, and then returns a set of credentials
func (*Server) HealthHandler ¶
func (s *Server) HealthHandler(w http.ResponseWriter, req *http.Request)
HealthHandler is a health check endpoint that just returns a 200 to show the server is now alive and handling traffic.
func (*Server) LoginHandler ¶
func (s *Server) LoginHandler(w http.ResponseWriter, req *http.Request)
LoginHandler redirects a client to the Google OAuth login page
func (*Server) RegisterRoute ¶
RegisterRoute registers a single route
func (*Server) RegisterRoutes ¶
RegisterRoutes registers multiple routes