httpctx

package
v0.0.0-...-c1a3bfb Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package httpctx provides a context-aware HTTP handler adaptor

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	Ctx     context.Context
	Handler Handler
}

Adapter turns a context.Handler to an http.Handler

func (*Adapter) ServeHTTP

func (ca *Adapter) ServeHTTP(
	rw http.ResponseWriter, req *http.Request,
)

type Handler

type Handler interface {
	ServeHTTPContext(context.Context, http.ResponseWriter, *http.Request)
}

Handler is a request handler with an added context

func StripPrefix

func StripPrefix(prefix string, h Handler) Handler

StripPrefix strips a prefix from the request URL

type HandlerFunc

type HandlerFunc func(context.Context, http.ResponseWriter, *http.Request)

A HandlerFunc is an adaptor to turn a function in to a Handler

func (HandlerFunc) ServeHTTPContext

func (h HandlerFunc) ServeHTTPContext(
	ctx context.Context, rw http.ResponseWriter, req *http.Request,
)

ServeHTTPContext calls the underlying handler function

Jump to

Keyboard shortcuts

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