webserver

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2021 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WebServer

type WebServer struct {
	// csrf handler definitions
	CsrfErrorHandler       func(c *gin.Context)
	CsrfTokenGetterHandler func(c *gin.Context) string

	// http error handler definitions
	HttpStatusErrorHandler func(status int, trace string, c *gin.Context)

	// jwt auth handler definitions
	LoginRequestDataPtr interface{}

	AuthenticateHandler func(loginRequestDataPtr interface{}) (loggedInCredentialPtr interface{})
	AddClaimsHandler    func(loggedInCredentialPtr interface{}) (identityKeyValue string, claims map[string]interface{})
	GetIdentityHandler  func(claims map[string]interface{}) interface{}
	AuthorizerHandler   func(loggedInCredentialPtr interface{}, c *gin.Context) bool

	LoginResponseHandler        func(c *gin.Context, statusCode int, token string, expires time.Time)
	LogoutResponseHandler       func(c *gin.Context, statusCode int)
	RefreshTokenResponseHandler func(c *gin.Context, statusCode int, token string, expires time.Time)

	UnauthorizedHandler      func(c *gin.Context, code int, message string)
	NoRouteHandler           func(claims map[string]interface{}, c *gin.Context)
	MiddlewareErrorEvaluator func(e error, c *gin.Context) string
	TimeHandler              func() time.Time

	// route definitions
	Routes map[string]*ginw.RouteDefinition
	// contains filtered or unexported fields
}

WebServer defines gin http web server, loads config from yaml config file, contains fields to config custom handlers

func NewWebServer

func NewWebServer(appName string, configFileName string, customConfigPath string) *WebServer

NewWebServer creates a prepared web server for further setup and use

func (*WebServer) ExtractJwtClaims

func (w *WebServer) ExtractJwtClaims(c *gin.Context) map[string]interface{}

ExtractJwtClaims returns map from gin context extract

func (*WebServer) Port added in v1.0.6

func (w *WebServer) Port() uint

Port returns the web server port configured

func (*WebServer) Serve

func (w *WebServer) Serve() error

Serve will setup and start the web server

func (*WebServer) SetRouteGroupCustomMiddleware

func (w *WebServer) SetRouteGroupCustomMiddleware(routeGroupName string, routerFunc []gin.HandlerFunc) bool

SetRouterGroupCustomMiddleware sets additional custom gin middleware (RouterFunc) to engine or router groups,

routerGroupName = blank, to set routerFunc to engine routerGroupName = not blank, to set routerFunc to the named router group if found

return true if set; false if not set

func (*WebServer) UseTls added in v1.0.7

func (w *WebServer) UseTls() bool

UseTls indicates if the web server uses tls (https), otherwise, http

Jump to

Keyboard shortcuts

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