http

package
v2.0.6 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler interface {
	// ServeHTTP should handle HTTP requests.
	ServeHTTP(w http.ResponseWriter, r *http.Request)

	// AddRoute should allow the handler to configure itself accepting a router.
	AddRoute(r *mux.Router)
}

Handler is responsible for defining a HTTP request route and corresponding handler.

type HttpService

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

HttpService is the struct that will hold references to all necessary data for running an http server.

func NewHttpService

func NewHttpService(port int) *HttpService

NewHttpService will run the setup process and create a Service that can be used to run a http api.

func (*HttpService) AddRoutes

func (h *HttpService) AddRoutes(handlers ...Handler)

AddRoutes can be used to let each Handler setup their service routing.

func (*HttpService) Close

func (h *HttpService) Close() error

Close will teardown/close any resources used by this http service.

func (*HttpService) Start

func (h *HttpService) Start() error

Start will begin listening on the host:port for requests. Blocking call.

type NotFoundHandler

type NotFoundHandler struct {
}

NotFoundHandler struct configures and responds to all invalid paths.

func NewNotFoundHandler

func NewNotFoundHandler() *NotFoundHandler

NewNotFoundHandler creates a new NotFoundHandler and returns a pointer.

func (*NotFoundHandler) AddRoute

func (h *NotFoundHandler) AddRoute(r *mux.Router)

AddRoute allows to configure itself accepting a router.

func (*NotFoundHandler) Handle

func (h *NotFoundHandler) Handle(w http.ResponseWriter, r *http.Request)

Handle will handle HTTP requests.

Jump to

Keyboard shortcuts

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