httpServerModel

package
v0.0.0-...-80164ef Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestIDHeaderName       = "X-Request-ID"
	HeaderContentType         = "Content-Type"
	HeaderContentLength       = "Content-Length"
	HeaderXContentTypeOptions = "X-Content-Type-Options"
)
View Source
const (
	ReadyURL  = "/readyz"
	HealthURL = "/healthz"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CORS

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

func NewCORS

func NewCORS() *CORS

func (*CORS) AddHeader

func (c *CORS) AddHeader(header ...string)

func (*CORS) AddOrigin

func (c *CORS) AddOrigin(origin ...string)

func (*CORS) AllowedHeaders

func (c *CORS) AllowedHeaders() []string

func (*CORS) AllowedOrigins

func (c *CORS) AllowedOrigins() []string

type Config

type Config struct {
	ReadTimeout     int
	WriteTimeout    int
	IdleTimeOut     int
	ShutdownTimeout int

	CORS *CORS
	// contains filtered or unexported fields
}

func NewDefaultConfig

func NewDefaultConfig(port int) *Config

func (*Config) IsContainMiddlewares

func (c *Config) IsContainMiddlewares() bool

func (*Config) Middlewares

func (c *Config) Middlewares() []func(http.Handler) http.Handler

func (*Config) Port

func (c *Config) Port() int

func (*Config) PrivateHandlers

func (c *Config) PrivateHandlers() []*RequestHandler

func (*Config) PublicHandlers

func (c *Config) PublicHandlers() []*RequestHandler

func (*Config) RegisterMiddleware

func (c *Config) RegisterMiddleware(middleware func(http.Handler) http.Handler)

func (*Config) RegisterPrivateHandler

func (c *Config) RegisterPrivateHandler(method, route string, handlerFn http.HandlerFunc)

func (*Config) RegisterPublicHandler

func (c *Config) RegisterPublicHandler(method, route string, handlerFn http.HandlerFunc)

type ErrorResponse

type ErrorResponse struct {
	Errors []ErrorResponseData `json:"errors"`
}

func NewErrorResponse

func NewErrorResponse(errorsData []ErrorResponseData) ErrorResponse

func NewSingleErrorResponse

func NewSingleErrorResponse(errorData ErrorResponseData) ErrorResponse

func (ErrorResponse) FirstHttpCode

func (r ErrorResponse) FirstHttpCode() int

type ErrorResponseData

type ErrorResponseData struct {
	HttpCode  int    `json:"responseCode"`
	ErrorCode string `json:"errorCode"`
	Text      string `json:"text"`
}

type RequestHandler

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

func (*RequestHandler) HandlerFunc

func (h *RequestHandler) HandlerFunc() http.HandlerFunc

func (*RequestHandler) Method

func (h *RequestHandler) Method() string

func (*RequestHandler) Route

func (h *RequestHandler) Route() string

Jump to

Keyboard shortcuts

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