http

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: May 26, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RID added in v0.0.8

func RID(c echo.Context) string

RID is a short function that the echo context can be passed into, which returns the request ID as it grabs it from the response header. The upside of this over the custom context is that a custom context is not required.

Types

type Context added in v0.0.8

type Context struct {
	echo.Context
}

func (*Context) RequestID added in v0.0.8

func (c *Context) RequestID() string

RequestID will return the request ID stored in the echo.HeaderXRequestID header on the http.Response, or "unknown-request" if the value of the header was an empty string.

Importantly this is on the response header because the request headers are expected to come from outside the service.

type Handler

type Handler func(ctx context.Context, w http.ResponseWriter, r *http.Request) error

Handler is a function signature which retains most of the important bits of http.HandlerFunc, but enhances it with an incoming context, so we don't need to mangle the one in http.Request, and returns an error, which will be useful once we have an error handling middleware.

func WrapMiddleware

func WrapMiddleware(mw []Middleware, handler Handler) Handler

WrapMiddleware creates a new handler by wrapping middleware around a final handler. The middlewares' Handlers will be executed by requests in the order they are provided.

type Middleware

type Middleware func(h Handler) Handler

Middleware is a function signature that takes a Handler, and returns a Handler. The idea here is that the passed in Handler is going to be wrapped into whatever functionality we need, and then the new, enhanced Handler gets returned.

Jump to

Keyboard shortcuts

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