Documentation ¶
Index ¶
- func WithAllowedCreds(server *Server)
- func WithAllowedHeaders(headers ...string) func(*Server)
- func WithAllowedMethods(methods ...string) func(*Server)
- func WithAllowedOrgins(origins ...string) func(*Server)
- func WithAllowedOrigins(origins ...string) func(*Server)
- type Server
- func (s *Server) Apply(options ...func(*Server))
- func (server *Server) Hello(w http.ResponseWriter, r *http.Request)
- func (server *Server) OpenSocket(w http.ResponseWriter, r *http.Request)
- func (s Server) Register(route string, h http.HandlerFunc, ...)
- func (s Server) Start(host string) error
- func (s *Server) WithAuth(next http.HandlerFunc) http.HandlerFunc
- func (s *Server) WithCors(next http.HandlerFunc) http.HandlerFunc
- func (s *Server) WithTicketAuth(next http.HandlerFunc) http.HandlerFunc
- func (s *Server) WithTraceIP(next http.HandlerFunc) http.HandlerFunc
- func (s Server) WithTracing(next http.HandlerFunc) http.HandlerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithAllowedCreds ¶
func WithAllowedCreds(server *Server)
WithAllowedCreds set the response Header of "Access-Control-Allow-Credentials" to true
func WithAllowedHeaders ¶
WithAllowedHeaders apply the given http.Methods to the allowed Headers on the API
func WithAllowedMethods ¶
WithAllowedMethods apply the given http.Methods to the allowed Methods on the API
func WithAllowedOrgins ¶
WithAllowedOrigins apply the given Origins to the allowed Origins on the API
func WithAllowedOrigins ¶
WithAllowedOrigins overrides the default setting for "Access-Control-Allow-Origin: *" with the given origins
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewDefault ¶
func NewDefault( appTokenClient client.ClientAppToken, appConfigClient client.ClientAppConfig, csqlClient *cassandra.Client) *Server
func (*Server) Hello ¶
func (server *Server) Hello(w http.ResponseWriter, r *http.Request)
Hello takes care about verifing that the user has the right to be tracked (lol sounds funny) It therfore performs all authentication and authrorization checks, loading meta data the client needs
func (*Server) OpenSocket ¶
func (server *Server) OpenSocket(w http.ResponseWriter, r *http.Request)
func (Server) Register ¶
func (s Server) Register(route string, h http.HandlerFunc, middleware ...func(http.HandlerFunc) http.HandlerFunc)
func (*Server) WithAuth ¶
func (s *Server) WithAuth(next http.HandlerFunc) http.HandlerFunc
WithAuth acts as middleware before route endpoints. It checks if a user is authenticated or not returns a new http.HandlerFunc to allow multiple other middleware to be wrapped around/after
func (*Server) WithCors ¶
func (s *Server) WithCors(next http.HandlerFunc) http.HandlerFunc
WithCors apply the CORS-Configs of the API to a given API-Endpoint
func (*Server) WithTicketAuth ¶
func (s *Server) WithTicketAuth(next http.HandlerFunc) http.HandlerFunc
WithTicketAuth looks for the from this service issued web-socket ticket and validates the ticket - if of it passed the request forward to the next caller else returns with a http error
func (*Server) WithTraceIP ¶
func (s *Server) WithTraceIP(next http.HandlerFunc) http.HandlerFunc
WithTraceIP adds the requester's client IP to the request context serving as device identifier - if none present request is not accpeted
func (Server) WithTracing ¶
func (s Server) WithTracing(next http.HandlerFunc) http.HandlerFunc
WithTracing allows to generate a tracing ID at the entry-point of an request which gets added in the request.Context in order for it to be available through out the code. The tracing ID is an straight forward approach to trace logs from multiple services The Tracing ID is based on the current time and the MAC-Address