httputil

package
v0.0.0-...-cd3ace8 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(ctx context.Context, addr string, handler http.Handler, shutdownContext ContextFunc) error

ListenAndServe is run http.ListenAndServe and cancellation by context.Context.

func ListenAndServeServer

func ListenAndServeServer(ctx context.Context, s *http.Server, shutdownContext ContextFunc) error

ListenAndServeServer is run http.Server.ListenAndServe and cancellation by context.Context.

func ListenAndServeTLS

func ListenAndServeTLS(ctx context.Context, addr string, certFile string, keyFile string, handler http.Handler, shutdownContext ContextFunc) error

ListenAndServeTLS is run http.ListenAndServeTLS and cancellation by context.Context.

func ListenAndServeTLSServer

func ListenAndServeTLSServer(ctx context.Context, s *http.Server, certFile string, keyFile string, shutdownContext ContextFunc) error

ListenAndServeTLSServer is run http.Server.ListenAndServeTLS and cancellation by context.Context.

Types

type ContextFunc

type ContextFunc func() (context.Context, context.CancelFunc)

ContextFunc is factory of context.Context.

type MethodHandler

type MethodHandler struct {
	GET     http.Handler // HTTP GET
	HEAD    http.Handler // HTTP HEAD
	POST    http.Handler // HTTP POST
	PUT     http.Handler // HTTP PUT
	PATCH   http.Handler // HTTP PATCH
	DELETE  http.Handler // HTTP DELETE
	CONNECT http.Handler // HTTP CONNECT
	OPTIONS http.Handler // HTTP OPTIONS
	TRACE   http.Handler // HTTP TRACE
	Default http.Handler // Default handler
}

MethodHandler is router by HTTP method.

func (*MethodHandler) ServeHTTP

func (h *MethodHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP is implementation of http.Handler.

type ServeMux

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

ServeMux is an HTTP request multiplexer.

func NewServeMux

func NewServeMux() *ServeMux

NewServeMux is return new ServeMux instance.

func (*ServeMux) Handle

func (m *ServeMux) Handle(pattern string, handler http.Handler, middlewares ...middleware.Middleware)

Handle registers the handler for the given pattern. Middlewares is processed after registered middleware by UseMiddleware and process before handlers are executed. If a handler already exists for pattern, Handle panics.

func (*ServeMux) HandleFunc

func (m *ServeMux) HandleFunc(pattern string, handler http.HandlerFunc, middlewares ...middleware.Middleware)

HandleFunc registers the handler function for the given pattern. Middlewares is processed after registered middleware by UseMiddleware and process before handlers are executed.

func (*ServeMux) ServeHTTP

func (m *ServeMux) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP is implementation of http.Handler.

func (*ServeMux) UseMiddleware

func (m *ServeMux) UseMiddleware(middlewares ...middleware.Middleware)

UseMiddleware is register middleware. Middleware is processed before all handlers are executed.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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