Help us shape the future of Go! Take the 2026 Go Developer Survey

webutil

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: MIT Imports: 21 Imported by: 0

README

webutil

Maintainer GoVersion GoDoc GoReportCard codecov

Web-related utilities for Go microservices.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigureGinCORS

func ConfigureGinCORS(
	router *gin.Engine,
	allowedOrigins []string,
	allowMethods []string,
	allowHeaders []string,
	exposeHeaders []string,
	maxAge time.Duration,
	disableCredentials bool)

func CreateAuth0JWTValidationGinMiddleware added in v0.0.2

func CreateAuth0JWTValidationGinMiddleware(
	auth0Domain string,
	audiences []string,
	algorithm validator.SignatureAlgorithm,
	customClaimsFunc func() validator.CustomClaims,
	tokenExtractors ...jwtmiddleware.TokenExtractor) func(c *gin.Context)

func GetAccessToken added in v0.0.2

func GetAccessToken(auth0Domain, m2mClientID, m2mClientSecret, apiAudience string) (string, error)

func GetClaims added in v0.0.2

func GetClaims(ctx context.Context) *validator.ValidatedClaims

func GinAccessLogMiddleware

func GinAccessLogMiddleware(c *gin.Context)

func GraphErrorPresenter added in v0.0.3

func GraphErrorPresenter(ctx context.Context, e error) *gqlerror.Error

func GraphPanicRecoverer added in v0.0.3

func GraphPanicRecoverer(_ context.Context, p interface{}) error

func HasScope added in v0.0.2

func HasScope(scopes, expectedScope string) bool

func InitGinPackage

func InitGinPackage(devMode bool)

func NewGin

func NewGin() *gin.Engine

Types

type CORSConfig

type CORSConfig struct {
	AllowedOrigins     []string      `` /* 241-byte string literal not displayed */
	AllowMethods       []string      `` /* 219-byte string literal not displayed */
	AllowHeaders       []string      `` /* 258-byte string literal not displayed */
	DisableCredentials bool          `` /* 216-byte string literal not displayed */
	ExposeHeaders      []string      `` /* 215-byte string literal not displayed */
	MaxAge             time.Duration `` /* 215-byte string literal not displayed */
}

func (*CORSConfig) Configure

func (c *CORSConfig) Configure(router *gin.Engine)

type GraphUserError added in v0.0.3

type GraphUserError struct {
	// contains filtered or unexported fields
}

func (*GraphUserError) Error added in v0.0.3

func (e *GraphUserError) Error() string

func (*GraphUserError) Is added in v0.0.3

func (e *GraphUserError) Is(err error) bool

func (*GraphUserError) Unwrap added in v0.0.3

func (e *GraphUserError) Unwrap() error

type HTTPConfig

type HTTPConfig struct {
	Port int        `env:"PORT" value-name:"PORT" long:"port" description:"Port to listen on" default:"8000"`
	CORS CORSConfig `group:"cors" namespace:"cors" env-namespace:"CORS"`
}

Jump to

Keyboard shortcuts

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