http

package
v0.0.6-alpha Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package http is a library designed to make working with the HTTP transport easier for jenny servers.

Index

Constants

View Source
const (
	// ContextKeyRequestMethod is populated in the context by
	// PopulateRequestContext. Its value is r.Method.
	ContextKeyRequestMethod contextKey = iota

	// ContextKeyRequestURI is populated in the context by
	// PopulateRequestContext. Its value is r.RequestURI.
	ContextKeyRequestURI

	// ContextKeyRequestURL is populated in the context by
	// PopulateRequestContext. Its value is r.RequestURI.
	ContextKeyRequestURL

	// ContextKeyRequestPath is populated in the context by
	// PopulateRequestContext. Its value is r.URL.Path.
	ContextKeyRequestPath

	// ContextKeyRequestProto is populated in the context by
	// PopulateRequestContext. Its value is r.Proto.
	ContextKeyRequestProto

	// ContextKeyRequestHost is populated in the context by
	// PopulateRequestContext. Its value is r.Host.
	ContextKeyRequestHost

	// ContextKeyRequestRemoteAddr is populated in the context by
	// PopulateRequestContext. Its value is r.RemoteAddr.
	ContextKeyRequestRemoteAddr

	// ContextKeyRequestXForwardedFor is populated in the context by
	// PopulateRequestContext. Its value is r.Header.Get("X-Forwarded-For").
	ContextKeyRequestXForwardedFor

	// ContextKeyRequestXForwardedProto is populated in the context by
	// PopulateRequestContext. Its value is r.Header.Get("X-Forwarded-Proto").
	ContextKeyRequestXForwardedProto

	// ContextKeyRequestAuthorization is populated in the context by
	// PopulateRequestContext. Its value is r.Header.Get("Authorization").
	ContextKeyRequestAuthorization

	// ContextKeyRequestReferer is populated in the context by
	// PopulateRequestContext. Its value is r.Header.Get("Referer").
	ContextKeyRequestReferer

	// ContextKeyRequestUserAgent is populated in the context by
	// PopulateRequestContext. Its value is r.Header.Get("User-Agent").
	ContextKeyRequestUserAgent

	// ContextKeyRequestXRequestID is populated in the context by
	// PopulateRequestContext. Its value is r.Header.Get("X-Request-Id").
	ContextKeyRequestXRequestID

	// ContextKeyRequestAccept is populated in the context by
	// PopulateRequestContext. Its value is r.Header.Get("Accept").
	ContextKeyRequestAccept

	// ContextKeyResponseHeaders is populated in the context whenever a
	// ServerFinalizerFunc is specified. Its value is of type http.Header, and
	// is captured only once the entire response has been written.
	ContextKeyResponseHeaders

	// ContextKeyResponseSize is populated in the context whenever a
	// ServerFinalizerFunc is specified. Its value is of type int64.
	ContextKeyResponseSize

	// ContextKeyCookies is populated with the Request cookies
	ContextKeyCookies

	// ContextKeyID is the X-Debug-ID header
	ContextKeyID

	// ContextKeyAccepts is the Accept header
	ContextKeyAccepts

	// ConetxtKeyContentType is the X-Debug-ID header
	ConetxtKeyContentType

	// ContextKeyRequestHeaders is the request headers
	ContextKeyRequestHeaders

	// ContextKeyUserAgent is the UserAgent in request
	ContextKeyUserAgent
)

Variables

View Source
var ErrCouldntFindAccepts = errors.New("can't find accepts in header")

ErrCouldntFindAccepts is returned when Accept mimeTypes can't be found in the header

Functions

func ContextAccepts

func ContextAccepts(ctx context.Context) (mime.Types, error)

ContextAccepts returns the accept specs if the request has been originated from a HTTP request

func ContextCookie

func ContextCookie(ctx context.Context, name string) *http.Cookie

ContextCookie return a cookie that was in the http.Request

func ContextRequestID

func ContextRequestID(ctx context.Context) []byte

ContextRequestID returns a unique id for the request

func PopulateRequestContext

func PopulateRequestContext(ctx context.Context, r *http.Request) context.Context

PopulateRequestContext populates values that should travel with the request context

Types

This section is empty.

Jump to

Keyboard shortcuts

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