handler

package
v1.0.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithHeaderParser

func WithHeaderParser(base http.Handler) http.Handler

WithHeaderParser is a custom middleware which used to fetch the header from incoming request and convert it to context.Context. Please take a note that we need to ignore "Accept", "Content-Type", and "Twirp-Version", all of these header's keys used by internal Twirp

func WithRecovery

func WithRecovery(base http.Handler) http.Handler

WithRecovery used to handle internal panic error, all panic will produce error http internal server error (500)

Types

type HTTPMiddleware

type HTTPMiddleware func(http.Handler) http.Handler

HTTPMiddleware used as alias type for http's middleware

type Service

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

Service used to wrap given framework.TwirpServiceBuilder We use this object to make handle with our custom middleware and make sure our service's object still compatible with our framework.TwirpServiceBuilder

func (*Service) PathPrefix

func (s *Service) PathPrefix() string

PathPrefix used to get path prefix from given service

func (*Service) ServeHTTP

func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP used as "proxy" to our internal http handler

func (*Service) Use

func (s *Service) Use(mw ...HTTPMiddleware)

Use attach multiple HTTPMiddleware

Jump to

Keyboard shortcuts

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