Documentation ¶
Index ¶
- type Endpoint
- type Logger
- type Opt
- func AddAllMiddleware(allMiddleware ...mux.MiddlewareFunc) Opt
- func AddAuthedEndpoint(authed ...Endpoint) Opt
- func AddAuthedMiddleware(authedMiddleware ...mux.MiddlewareFunc) Opt
- func AddEndpoint(public ...Endpoint) Opt
- func AddPublicMiddleware(publicMiddleware ...mux.MiddlewareFunc) Opt
- func CORSOptions(c cors.Options) Opt
- func DisableDefaultMiddleware(disable bool) Opt
- func HTTPPort(port int) Opt
- func HTTPSPort(port int) Opt
- func Handler(handler http.Handler) Opt
- func JWTSigningCertPath(path string) Opt
- func JWTSigningKey(key *rsa.PrivateKey) Opt
- func JWTSigningKeyPath(path string) Opt
- func JWTSingingKeyPassphrase(passphrase string) Opt
- func SetLanding(s string) Opt
- func SetLogger(logger Logger) Opt
- func SetTimeout(d time.Duration) Opt
- func TLSCertPath(path string) Opt
- func TLSKeyPath(path string) Opt
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Endpoint ¶
type Endpoint struct { Prefix bool Path string Method string Queries map[string]string Handler http.HandlerFunc }
Endpoint ...
type Logger ¶
type Logger interface { Infof(template string, args ...interface{}) Fatalf(template string, args ...interface{}) }
Logger is a logger you can use to optionally print out information
type Opt ¶
type Opt func(s *serverBuilder) error
Opt is an option for configuring the rest server
func AddAllMiddleware ¶
func AddAllMiddleware(allMiddleware ...mux.MiddlewareFunc) Opt
AddAllMiddleware adds a set of middleware to the server. Order matters here as first will be encountered first in a request.
func AddAuthedEndpoint ¶
AddAuthedEndpoint adds some authed endpoints to the server
func AddAuthedMiddleware ¶
func AddAuthedMiddleware(authedMiddleware ...mux.MiddlewareFunc) Opt
AddAuthedMiddleware adds a set of middleware to the server. Order matters here as first will be encountered first in a request.
func AddEndpoint ¶
AddEndpoint adds some public endpoints to the server
func AddPublicMiddleware ¶
func AddPublicMiddleware(publicMiddleware ...mux.MiddlewareFunc) Opt
AddPublicMiddleware adds a set of middleware to the server. Order matters here as first will be encountered first in a request.
func CORSOptions ¶
CORSOptions configures cors options for the server
func DisableDefaultMiddleware ¶
DisableDefaultMiddleware will disable the server from adding request fingerprinting prometheus metrics for all routes, and jwt auth for authed routes
func Handler ¶
Handler configures the rest handler that will route and respond to requests. Use this configuration if you want to route your own requests outside of this libary.
func JWTSigningCertPath ¶
JWTSigningCertPath configures the path to the public key that will be used to validate jwts. Defaults to the tls cert.
func JWTSigningKey ¶
func JWTSigningKey(key *rsa.PrivateKey) Opt
JWTSigningKey configures the path to the private key that will be used to validate the jwts. Defaults to the tls private key.
func JWTSigningKeyPath ¶
JWTSigningKeyPath configures the path to the private key that will be used to validate the jwts. Defaults to the tls private key.
func JWTSingingKeyPassphrase ¶
JWTSingingKeyPassphrase configures the passphrase that is required to use the signing key (if there is one).
func SetLanding ¶
SetLanding will set the top level home path for the server. Defaults to just the bare / If you are using a versioned api this will respect the versioning.
func SetTimeout ¶
SetTimeout sets the http timeout for requests and responses. Defaults to 10 seconds.
func TLSCertPath ¶
TLSCertPath configures the path to the tls certificate
func TLSKeyPath ¶
TLSKeyPath configures the path to the tls private key
type Server ¶
Server is a wrapper around the gorilla mux http server that manages signals Note that I don't use life' lifecycle here because we have a blocking call for run (so I don't use life.Close or life.Done for managing the background thread. I use the server.ListenAndServe and server.Shutdown).
func NewServer ¶
NewServer creates a new http server with a router. The reason why we pass through is because we are using a functional constructor and we don't want to pollute the main struct with intermediate config state
func (Server) StartAndListen ¶
func (s Server) StartAndListen()
StartAndListen synchronously will start the server and bypass the clean goRoutine handling that life provides. It will block while the server is listening