http

package
v0.0.0-...-fae0b3d Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Endpoint

type Endpoint struct {
	Method      Method
	Path        string
	Cors        *middleware.CORS
	Auth        middleware.Authenticator
	Handler     func(w http.ResponseWriter, r *http.Request)
	Middlewares []func(handlerFunc http.HandlerFunc) http.HandlerFunc
}

type Method

type Method string
const (
	GET    Method = "GET"
	POST   Method = "POST"
	PUT    Method = "PUT"
	PATCH  Method = "PATCH"
	DELETE Method = "DELETE"
	OPTION Method = "OPTION"
)

func (Method) String

func (m Method) String() string

type Server

type Server struct {
	Router *chi.Mux
	Port   string
	Host   string

	Middlewares *middleware.Middlewares
}

func New

func New(config *env.Config) *Server

func (*Server) AddSubRouter

func (s *Server) AddSubRouter(endpoint Endpoint) error

func (*Server) Respond

func (s *Server) Respond(w http.ResponseWriter, _ *http.Request, status int, data any)

func (*Server) Serve

func (s *Server) Serve() error

Jump to

Keyboard shortcuts

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