httpserver

package
v5.1.2 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HttpContentTypeJSON              = "application/json"
	HttpHeaderContentType            = "Content-Type"
	ContextKeyRequestBody            = ContextKey("ContextKeyRequestBody")
	ContextKeyHandlerError           = ContextKey("ContextKeyHandlerError")
	ContextKeyHandlerErrorStackTrace = ContextKey("ContextKeyHandlerErrorStackTrace")
)

Variables

This section is empty.

Functions

func MethodNotAllowed

func MethodNotAllowed() http.HandlerFunc

func NotFound

func NotFound() http.HandlerFunc

func SetDefaultPagination

func SetDefaultPagination(filter interface{}, defaultSortBy string) error

Types

type ContextKey

type ContextKey string

type DocumentationConfig

type DocumentationConfig struct {
	DocHost           string
	SwaggerRootFolder string
}

type Filter

type Filter struct {
	PageNo int64  `json:"pageNo" schema:"pageNo"`
	Limit  int64  `json:"limit" schema:"limit"`
	SortBy string `json:"sortBy" schema:"sortBy"`
	Asc    bool   `json:"asc" schema:"asc"`
}

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 errors.ErrorNotifier) *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) GetCacheRequestBody

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

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) HandleExceptionMiddleware

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

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) 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) SetErrorInContext

func (h *HTTPServer) SetErrorInContext(ctx context.Context, err error)

func (*HTTPServer) SetStackTrackInContext

func (h *HTTPServer) SetStackTrackInContext(ctx context.Context, stackTrace string)

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) 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