httpserver

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2025 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HeaderXCorrelationId = "X-Correlation-ID"
View Source
var HeaderXRequestId = "X-Request-ID"

Functions

func GetLoggerFromContext added in v0.2.0

func GetLoggerFromContext(ctx *gin.Context) *log.Entry

func SetCors

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

Types

type ContextKey

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

func (ContextKey) String

func (ck ContextKey) String() string

type HttpServer

type HttpServer struct {
	Gin *gin.Engine
	// contains filtered or unexported fields
}

func NewHttpServer

func NewHttpServer(config *domain.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) GetCorrelationID

func (hs *HttpServer) GetCorrelationID(ctx *gin.Context) string

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)

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

type Response

type Response struct {
	StatusCode int `json:"status"`

	Body  interface{}           `json:"body,omitempty"`
	Error *domain.ResponseError `json:"error,omitempty"`

	RequestId string `json:"requestId,omitempty"`
	ContextId string `json:"contextId,omitempty"`
}

Directories

Path Synopsis
contract module

Jump to

Keyboard shortcuts

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