server

package
v0.0.0-...-e951c9a Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2022 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrClientCanceled   = "The request was cancelled by the client."
	ErrDeadlineExceeded = "" /* 160-byte string literal not displayed */
)
View Source
const StatusClientClosedRequest = 499

StatusClientClosedRequest is the status code for when a client request cancellation of an http request

Variables

View Source
var (
	RecoveryHTTPMiddleware = middleware.Func(func(next http.Handler) http.Handler {
		return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
			defer func() {
				if p := recover(); p != nil {
					WriteError(onPanic(p), w)
				}
			}()
			next.ServeHTTP(w, req)
		})
	})
	RecoveryGRPCStreamInterceptor = grpc_recovery.StreamServerInterceptor(grpc_recovery.WithRecoveryHandler(onPanic))
	RecoveryGRPCUnaryInterceptor  = grpc_recovery.UnaryServerInterceptor(grpc_recovery.WithRecoveryHandler(onPanic))
)

Functions

func CacheGenNumberHeaderSetterMiddleware

func CacheGenNumberHeaderSetterMiddleware(cacheGenNumbersLoader queryrangebase.CacheGenNumberLoader) middleware.Interface

middleware for setting cache gen header to let consumer of response know all previous responses could be invalid due to delete operation

func ClientHTTPStatusAndError

func ClientHTTPStatusAndError(err error) (int, error)

ClientHTTPStatusAndError returns error and http status that is "safe" to return to client without exposing any implementation details.

func NewPrepopulateMiddleware

func NewPrepopulateMiddleware() middleware.Interface

NewPrepopulateMiddleware creates a middleware which will parse incoming http forms. This is important because some endpoints can POST x-www-form-urlencoded bodies instead of GET w/ query strings.

func ResponseJSONMiddleware

func ResponseJSONMiddleware() middleware.Interface

func WriteError

func WriteError(err error, w http.ResponseWriter)

WriteError write a go error with the correct status code.

Types

This section is empty.

Jump to

Keyboard shortcuts

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