httpserver

package
v5.6.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HttpContentTypeJSON   = "application/json"
	HttpHeaderContentType = "Content-Type"
)

Variables

This section is empty.

Functions

func MethodNotAllowed

func MethodNotAllowed() http.HandlerFunc

func NotFound

func NotFound() http.HandlerFunc

Types

type ContextKey

type ContextKey string

type DocumentationConfig

type DocumentationConfig struct {
	DocHost           string
	SwaggerRootFolder string
}

type HTTP2Config

type HTTP2Config struct {
	PublicKeyPath  string
	PrivateKeyPath string
}

type HTTPServer

type HTTPServer struct {
	*baseapp.BaseApp
	// contains filtered or unexported fields
}

func New

func New(appConfig HTTPServerConfig, logger log.Log, tr Tracer, errorNotifier notifier.Notifier) *HTTPServer

func (*HTTPServer) AddMiddleware

func (h *HTTPServer) AddMiddleware(middleware ...gin.HandlerFunc)

func (*HTTPServer) BootstrapServer

func (h *HTTPServer) BootstrapServer(ctx context.Context, handler http.Handler) error

func (*HTTPServer) CopyRequestBody

func (h *HTTPServer) CopyRequestBody(r *http.Request) ([]byte, error)

func (*HTTPServer) ExtractRequestMetadata

func (h *HTTPServer) ExtractRequestMetadata(r *http.Request) map[string]any

func (*HTTPServer) GetCorrelationParams

func (h *HTTPServer) GetCorrelationParams(r *http.Request) *log.CorrelationParam

func (*HTTPServer) GetCustomerID

func (h *HTTPServer) GetCustomerID(r *http.Request) *log.CustomerIdentifier

func (*HTTPServer) GetMaskedRequestMeta

func (h *HTTPServer) GetMaskedRequestMeta(r *http.Request) map[string]any

func (*HTTPServer) GetPort

func (h *HTTPServer) GetPort() string

func (*HTTPServer) GetRequestBody

func (h *HTTPServer) GetRequestBody(r *http.Request) ([]byte, error)

func (*HTTPServer) GetRouter

func (h *HTTPServer) GetRouter() *gin.Engine

func (*HTTPServer) GetSpanFromContext

func (h *HTTPServer) GetSpanFromContext(ctx context.Context) (span.Span, bool)

func (*HTTPServer) HealthCheck

func (h *HTTPServer) HealthCheck(w http.ResponseWriter, r *http.Request)

func (*HTTPServer) LoadRequestJSONBody

func (h *HTTPServer) LoadRequestJSONBody(r *http.Request, body any) error

func (*HTTPServer) LogRequestResponseMiddleware

func (h *HTTPServer) LogRequestResponseMiddleware() gin.HandlerFunc

func (*HTTPServer) Name

func (h *HTTPServer) Name(ctx context.Context) string

func (*HTTPServer) PanicHandleMiddleware added in v5.3.0

func (h *HTTPServer) PanicHandleMiddleware() gin.HandlerFunc

func (*HTTPServer) RequestTimerMiddleware

func (h *HTTPServer) RequestTimerMiddleware() gin.HandlerFunc

func (*HTTPServer) ServeHTTP

func (h *HTTPServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*HTTPServer) SetContextMiddleware

func (h *HTTPServer) SetContextMiddleware() gin.HandlerFunc

func (*HTTPServer) SetupDocumentation

func (h *HTTPServer) SetupDocumentation(ctx context.Context)

func (*HTTPServer) SetupRouter

func (h *HTTPServer) SetupRouter(ctx context.Context)

func (*HTTPServer) Shutdown

func (h *HTTPServer) Shutdown(ctx context.Context) error

func (*HTTPServer) StartH2CServer

func (h *HTTPServer) StartH2CServer()

func (*HTTPServer) StartServer

func (h *HTTPServer) StartServer()

func (*HTTPServer) StartTLSServer

func (h *HTTPServer) StartTLSServer()

func (*HTTPServer) Status

func (h *HTTPServer) Status(w http.ResponseWriter, r *http.Request)

func (*HTTPServer) StatusCheck

func (h *HTTPServer) StatusCheck(ctx context.Context) (any, error)

func (*HTTPServer) WriteErrorResponse added in v5.3.0

func (h *HTTPServer) WriteErrorResponse(ctx context.Context, w http.ResponseWriter, err error, includeStackTrace bool)

func (*HTTPServer) WriteJSON

func (h *HTTPServer) WriteJSON(ctx context.Context, w http.ResponseWriter, responseBody any)

func (*HTTPServer) WriteJSONWithStatusCode

func (h *HTTPServer) WriteJSONWithStatusCode(ctx context.Context, w http.ResponseWriter, statusCode int, responseBody any)

func (*HTTPServer) WriteResponse

func (h *HTTPServer) WriteResponse(ctx context.Context, w http.ResponseWriter, contentType string, responseBody []byte)

func (*HTTPServer) WriteResponseWithStatusCode

func (h *HTTPServer) WriteResponseWithStatusCode(ctx context.Context, w http.ResponseWriter, statusCode int, contentType string, responseBody []byte)

type HTTPServerConfig

type HTTPServerConfig struct {
	baseapp.ServerConfig
	DocumentationConfig
	*HTTP2Config
	Host string
	Port string
	Log  *LogConfig
}

type LogConfig

type LogConfig struct {
	AuthHeaderKeyList []string
}

type Tracer

type Tracer interface {
	GetGinMiddleware(serviceName string) gin.HandlerFunc
	span.SpanOp
}

Directories

Path Synopsis
h2c

Jump to

Keyboard shortcuts

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