http

package
v0.0.0-...-0f594a8 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2023 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMalformedAccept = errors.New("malformed Accept header")
)

Functions

func GetPageLang

func GetPageLang(query, header, defaultLang string) string

func GetPaginationFromURL

func GetPaginationFromURL(u *url.URL, defaultCount int) (int, int, bool)

GetPaginationFromURL returns a page and item count derived from the url query returns true if count is present in query.

func NewClient

func NewClient(application, version, endpoint string) *http.Client

func ReturnError

func ReturnError(w http.ResponseWriter, status int, errStr string, vars ...interface{})

Types

type ContextKey

type ContextKey int
const (
	ContextKeyAccept ContextKey = iota
)

type Module

type Module interface {
	Name() string
	Route(s *Server) error
	SetServer(s *Server)
}

Module represents a module that can be added to a http server.

type Server

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

Server is a http 2 web server.

func NewServer

func NewServer(_ context.Context, address, serviceName string) (*Server, error)

NewServer creates a new http web server.

func (*Server) HandleFunc

func (s *Server) HandleFunc(path string, f func(http.ResponseWriter, *http.Request)) *mux.Route

HandleFunc attaches a function to a path.

func (*Server) MethodNotAllowedHandler

func (s *Server) MethodNotAllowedHandler() http.Handler

func (*Server) NotFoundHandler

func (s *Server) NotFoundHandler() http.Handler

func (*Server) PathPrefix

func (s *Server) PathPrefix(path string) *mux.Route

PathPrefix attaches a new route url path prefix.

func (*Server) Start

func (s *Server) Start() error

Start starts the web server.

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop shuts down the web server.

func (*Server) WrapInMiddlewares

func (s *Server) WrapInMiddlewares(h http.Handler) http.Handler

WrapInMiddlewares wraps an http.Handler in the server's middleware.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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