http

package
v0.0.0-...-c196421 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chain

func Chain(h http.Handler, ms ...Middleware) http.Handler

Chain wraps a handler with multiple middleware. The provided middleware are iterated through in reverse order. This means that the first provided middleware will be called first when a request is handled. For example, given the following function call

Chain(baseHandler, loggingMiddleware, authMiddleware)

a request would go through the loggingMiddleware, then the authMiddleware, then be handled by the base handler.

Types

type AuthController

type AuthController struct {
	Service auth.Service
}

func (*AuthController) Register

func (c *AuthController) Register(router *httprouter.Router)

type ClientController

type ClientController struct {
	Service client.Service
}

func (*ClientController) GetClientByID

func (c *ClientController) GetClientByID(w http.ResponseWriter, r *http.Request)

func (*ClientController) Register

func (c *ClientController) Register(router *httprouter.Router)

func (*ClientController) RegisterClient

func (c *ClientController) RegisterClient(w http.ResponseWriter, r *http.Request)

type Middleware

type Middleware func(http.Handler) http.Handler

Middleware is a function that wraps a handler with additional behavior.

type Registerer

type Registerer interface {
	Register(*httprouter.Router)
}

Registerer represents a type that can register its routes. Generally, this is a controller that registers all of the routes for its domain.

type Server

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

Server is a wrapper around net/http.Server that allows for route registration. The server provides the standard loggingMiddleware which will be called before all requests.

func NewServer

func NewServer(addr string, logger level.Logger) (*Server, error)

NewServer constructs a new server object with all of the default values.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe begins listening for requests, and handles them using the registered handlers. This method will always return a non-nil error.

func (*Server) RegisterRoutes

func (s *Server) RegisterRoutes(rs ...Registerer)

RegisterRoutes registers all of the provided routes. If a route is registered multiple times, this function will panic.

type UserController

type UserController struct {
	Service user.Service
}

func (*UserController) GetByID

func (c *UserController) GetByID(w http.ResponseWriter, r *http.Request)

func (*UserController) Register

func (c *UserController) Register(router *httprouter.Router)

func (*UserController) RegisterUser

func (c *UserController) RegisterUser(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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