server

package
v0.0.0-...-30f0aeb Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractHeaderBearerToken

func ExtractHeaderBearerToken(r *http.Request, header string) (string, bool)

func HandleError

func HandleError(handle Handler) http.HandlerFunc

func RespondAggregateError

func RespondAggregateError(w http.ResponseWriter, statusCode int, err errors.AggregatedError) error

func RespondError

func RespondError(w http.ResponseWriter, err errors.AppError) error

func RespondJSON

func RespondJSON(w http.ResponseWriter, statusCode int, data any) error

func RespondNoContent

func RespondNoContent(w http.ResponseWriter)

Types

type ErrorResponse

type ErrorResponse struct {
	Code    string `json:"code,omitempty"`
	Field   string `json:"field,omitempty"`
	Message string `json:"message,omitempty"`
}

type ErrorResponseWrapper

type ErrorResponseWrapper struct {
	Errors []ErrorResponse `json:"errors,omitempty"`
}

func NewErrorResponseWrapper

func NewErrorResponseWrapper(errs ...error) ErrorResponseWrapper

type GroupRoute

type GroupRoute struct {
	Path        string
	GroupRoutes []GroupRoute
	Middlewares []Middleware
	Routes      []Route
}

type Handler

type Handler func(w http.ResponseWriter, r *http.Request) error

type Middleware

type Middleware func(next http.Handler) http.Handler

type Route

type Route struct {
	Method      string
	Path        string
	Middlewares []Middleware
	Handler     Handler
}

type Server

type Server interface {
	NewServer(groupRoutes []GroupRoute) *http.Server
	Start(httpServer *http.Server) error
	StartTest(httpServer *http.Server) *httptest.Server
}

func NewGoChiServer

func NewGoChiServer(config configs.Config) Server

func ProviderSet

func ProviderSet(
	config configs.Config,
) Server

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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