httpserver

package
v0.0.0-...-a67b36e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

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

func WithAllowedHeaders(headers ...string) func(*Server)

WithAllowedHeaders apply the given http.Methods to the allowed Headers on the API

func WithAllowedMethods

func WithAllowedMethods(methods ...string) func(*Server)

WithAllowedMethods apply the given http.Methods to the allowed Methods on the API

func WithAllowedOrgins

func WithAllowedOrgins(origins ...string) func(*Server)

WithAllowedOrigins apply the given Origins to the allowed Origins on the API

func WithAllowedOrigins

func WithAllowedOrigins(origins ...string) func(*Server)

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) Apply

func (s *Server) Apply(options ...func(*Server))

Apply applies an API-CORS configuration on the API instance

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) Start

func (s Server) Start(host string) error

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL