Documentation
¶
Index ¶
- func AuthedRequest(req *http.Request) *http.Request
- func CorsMiddleware(ctx huma.Context, next func(huma.Context))
- func FailOnError(err error, msg string)
- func GetDelLogTags(msg *amqp.Delivery) string
- func LoadConfig()
- func LogResponse(ctx context.Context, resp *http.Response, req *http.Request)
- func LogWithContext(ctx context.Context, msg ...string)
- func MockLoadConfig()
- func OidcMiddleware(ctx huma.Context, next func(huma.Context))
- func PrettyPrint(i interface{}) string
- func RegisterOidcProvider(ctx context.Context)
- func SendRequest(ctx context.Context, method string, sendUrl string, pBody *bytes.Reader, ...) (*http.Response, error)
- func TraceTagList(ctx context.Context) []string
- func TraceTags(ctx context.Context) string
- type ClientClaims
- type ConfigValues
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthedRequest ¶
Add the auth header to a request
func CorsMiddleware ¶
func CorsMiddleware(ctx huma.Context, next func(huma.Context))
Middleware to add cors headers
func FailOnError ¶
func GetDelLogTags ¶
func LoadConfig ¶
func LoadConfig()
LoadConfig loads and validates the configuration from a .env and environment variables
func LogResponse ¶
This isn't working for some reason
func LogWithContext ¶
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))
Middleware to provide authentication in cxt.Values("user.id")
func PrettyPrint ¶
func PrettyPrint(i interface{}) string
func RegisterOidcProvider ¶
Register an Oidc Provider
func SendRequest ¶
func SendRequest(ctx context.Context, method string, sendUrl string, pBody *bytes.Reader, timeout time.Duration) (*http.Response, error)
Post an unauthed request to the given url Returns the response or an error if requests statusCode is not 2xx uses to application/json content type for post bodies
func TraceTagList ¶
List of traceId, spanId for slog, can't get this working for some reason
Types ¶
type ClientClaims ¶
type ClientClaims struct { //The user id Uid string `json:"sub"` Groups []string `json:"groups"` jwt.RegisteredClaims }
Wrapper type for claims from the jwt
func Authorize ¶
func Authorize(w http.ResponseWriter, r *http.Request, allowedMethods []string, requiredScope string) (claims *ClientClaims, err error)
Extract a token, add cors headers, and validate the token
func ValidateToken ¶
func ValidateToken(ctx context.Context, tokenString string) (claims *ClientClaims, err error)
Validate a token and return the claims
type ConfigValues ¶
type ConfigValues struct { // RabbitMQ config MQ_HOST string `validate:"required"` MQ_PORT string `validate:"required"` MQ_USER string `validate:"required"` MQ_PASS string `validate:"required"` // Queue config GEN_XCHANGE string `validate:"required"` PROG_XCHANGE string `validate:"required"` // Prefix for exchanges and queues to enable different environments MQ_PREFIX string // OIDC config 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 to query machines and send results API_SEND_URL string // Port number for http server PORT_NUM int // Machine check interval in minutes MACHINE_FETCH_INTERVAL int // Machine status check interval in minutes CHECK_INTERVAL int // Restart check interval in milliseconds RESTART_CHECK_INTERVAL int // Router timeout in seconds ROUTER_TIMEOUT int // Max reqeues before dropping a message (total idle time for a gen would be router_timeout * (max_router_retry_count + ) MAX_ROUTER_RETRY_COUNT uint64 // OTLP config DEPLOYMENT_ENVIRONMENT_NAME string `validate:"required"` OTEL_SERVICE_NAME string `validate:"required"` OTEL_EXPORTER_OTLP_ENDPOINT string `validate:"required"` // Enable a debug consumer queue DEBUG_CONSUMER_QUEUE bool LOG_LEVEL string }
var Config *ConfigValues
func MockConfig ¶
func MockConfig() ConfigValues
func (*ConfigValues) GetDLXchange ¶
func (c *ConfigValues) GetDLXchange() string
func (*ConfigValues) GetDLXqueue ¶
func (c *ConfigValues) GetDLXqueue() string
func (*ConfigValues) GetGenXchange ¶
func (c *ConfigValues) GetGenXchange() string
func (*ConfigValues) GetLoggerLevel ¶
func (c *ConfigValues) GetLoggerLevel() slog.Level
func (*ConfigValues) GetMqUrl ¶
func (c *ConfigValues) GetMqUrl() string
func (*ConfigValues) GetProgXchange ¶
func (c *ConfigValues) GetProgXchange() string