httpserver

package module
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2025 License: MIT Imports: 22 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCorrelationID added in v0.2.2

func GetCorrelationID(ctx *gin.Context) string

func GetLoggerFromGinContext added in v0.2.2

func GetLoggerFromGinContext(ctx *gin.Context) (*log.Entry, error)

func GetMetricsFromContext added in v0.2.2

func GetMetricsFromContext(ctx *gin.Context) MetricsDomain.Point

func GetRequestID added in v0.2.2

func GetRequestID(ctx *gin.Context) string

func SetCors

func SetCors(router *gin.Engine, allowedOrigins []string)

Types

type HttpRequestMetric added in v0.2.3

type HttpRequestMetric struct {
	Method   string `metric:"method"`
	Path     string `metric:"path"`
	Status   int    `metric:"status"`
	Duration int64  `metric:"duration"`
}

type HttpServer

type HttpServer struct {
	Gin *gin.Engine

	Env env.Environment
	// contains filtered or unexported fields
}

func NewHttpServer

func NewHttpServer(env env.Environment, config *HttpConfig.HttpServerConfig) *HttpServer

func (*HttpServer) CreateLoggerForRequest added in v0.2.0

func (hs *HttpServer) CreateLoggerForRequest(ctx *gin.Context)

func (*HttpServer) CreateMetricsForRequest added in v0.2.0

func (hs *HttpServer) CreateMetricsForRequest(ctx *gin.Context)

func (*HttpServer) GetPath

func (gs *HttpServer) GetPath(ctx *gin.Context) string

func (*HttpServer) LogRequest added in v0.2.0

func (gs *HttpServer) LogRequest(c *gin.Context)

TODO: should find a way to log a point with the same key/values as the log entry without having to repeat the key/values setting (maybe an abstraction that can be used by both logrus and influxdb)

func (*HttpServer) MapHttpStatusToLoggingLevel

func (gs *HttpServer) MapHttpStatusToLoggingLevel(ctx *gin.Context) logrus.Level

func (*HttpServer) ProfileNextRequest

func (gs *HttpServer) ProfileNextRequest(ctx *gin.Context) time.Duration

func (*HttpServer) Reply

func (hs *HttpServer) Reply(ctx *gin.Context, body interface{})

func (*HttpServer) ReplyWithError

func (hs *HttpServer) ReplyWithError(ctx *gin.Context, err error)

func (*HttpServer) RequireCorrelationID

func (hs *HttpServer) RequireCorrelationID(ctx *gin.Context)

func (*HttpServer) RequireRequestID

func (hs *HttpServer) RequireRequestID(ctx *gin.Context)

func (*HttpServer) Run

func (gs *HttpServer) Run() error

Directories

Path Synopsis
contract module
httpserver
Package httpserver provides primitives to interact with the openapi HTTP API.
Package httpserver provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

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