hanayo/vendor/github.com/RangelReale/osin/server.go
2019-02-23 13:29:15 +00:00

33 lines
763 B
Go

package osin
import (
"time"
)
// Server is an OAuth2 implementation
type Server struct {
Config *ServerConfig
Storage Storage
AuthorizeTokenGen AuthorizeTokenGen
AccessTokenGen AccessTokenGen
Now func() time.Time
}
// NewServer creates a new server instance
func NewServer(config *ServerConfig, storage Storage) *Server {
return &Server{
Config: config,
Storage: storage,
AuthorizeTokenGen: &AuthorizeTokenGenDefault{},
AccessTokenGen: &AccessTokenGenDefault{},
Now: time.Now,
}
}
// NewResponse creates a new response for the server
func (s *Server) NewResponse() *Response {
r := NewResponse(s.Storage)
r.ErrorStatusCode = s.Config.ErrorStatusCode
return r
}