webserver

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: Apache-2.0 Imports: 16 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) GetHostAddress added in v1.1.0

func (w *WebServer) GetHostAddress() string

GetHostAddress returns either the dns based url as configured, if route53 dns url is configured, this function will first create dns recordset for the local ip, then return dns url

func (*WebServer) Port added in v1.0.6

func (w *WebServer) Port() uint

Port returns the web server port configured

func (*WebServer) RemoveDNSRecordset added in v1.1.0

func (w *WebServer) RemoveDNSRecordset()

RemoveDNSRecordset will delete dns resource recordset for the currently registered entry from route53 (originally registered via GetHostAddress function)

func (*WebServer) Serve

func (w *WebServer) Serve() error

Serve will setup and start the web server, in blocking mode

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