utils

package
v0.0.0-...-f3a1ebc Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthedRequest

func AuthedRequest(req *http.Request) *http.Request

func CorsMiddleware

func CorsMiddleware(ctx huma.Context, next func(huma.Context))

func Error424FailedDependency

func Error424FailedDependency(msg string, code int, errs ...error) huma.StatusError

Error424UnprocessableEntity returns a 424.

func FailOnError

func FailOnError(err error, msg string)

func GetDelLogTags

func GetDelLogTags(msg *amqp.Delivery) string

func GetEnv

func GetEnv(key, fallback string) string

func LoadConfig

func LoadConfig()

LoadConfig loads and validates the configuration from a .env and environment variables

func LogResponse

func LogResponse(ctx context.Context, resp *http.Response, req *http.Request)

func LogWithContext

func LogWithContext(ctx context.Context, msg ...string)

Logs the message and appends span/traceId tags from the passed context

func MockLoadConfig

func MockLoadConfig()

func OidcMiddleware

func OidcMiddleware(ctx huma.Context, next func(huma.Context))

func PrettyPrint

func PrettyPrint(i interface{}) string

func RegisterOidcProvider

func RegisterOidcProvider(ctx context.Context)

func TraceTags

func TraceTags(ctx context.Context) string

Types

type ClientClaims

type ClientClaims struct {
	//The user id
	Uid    string   `json:"sub"`
	Groups []string `json:"groups"`
	jwt.RegisteredClaims
}

func Authorize

func Authorize(w http.ResponseWriter, r *http.Request, allowedMethods []string, requiredScope string) (claims *ClientClaims, err error)

func ValidateToken

func ValidateToken(ctx context.Context, tokenString string) (claims *ClientClaims, err error)

type ConfigValues

type ConfigValues struct {
	MQ_HOST            string `validate:"required"`
	MQ_PORT            string `validate:"required"`
	MQ_USER            string `validate:"required"`
	MQ_PASS            string `validate:"required"`
	GEN_XCHANGE        string `validate:"required"`
	PROG_XCHANGE       string `validate:"required"`
	OIDC_ISSUER        string `validate:"required"`
	OIDC_CLIENT_ID     string `validate:"required"`
	OIDC_CLIENT_SECRET string `validate:"required"`
	GEN_HANDLER_SECRET string `validate:"required"`
	GEN_HANDLER_SA     string `validate:"required"`
	API_SEND_URL       string
	MQ_PREFIX          string
	PORT_NUM           int
	CHECK_INTERVAL     int
}
var Config *ConfigValues

func MockConfig

func MockConfig() ConfigValues

func (*ConfigValues) GetGenXchange

func (c *ConfigValues) GetGenXchange() string

func (*ConfigValues) GetMqUrl

func (c *ConfigValues) GetMqUrl() string

func (*ConfigValues) GetProgXchange

func (c *ConfigValues) GetProgXchange() string

Jump to

Keyboard shortcuts

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