httpserver

package
v0.0.0-alpha.2.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

package server provides the Agent HTTP server, which is the service, configured with the Agent Management Service.

package server provides the Agent HTTP server, which is the service, configured with the Agent Management Service.

Index

Constants

View Source
const (
	// Server Hostname and port are not configurable since the manager needs to know them for the Envoy cluster creation
	ServerHostname           string = "127.0.0.1"
	ServerPort               uint32 = 8090
	HeaderMockID                    = "X-Kusk-Mock-ID"
	HeaderMockResponseInsert        = "X-Kusk-Mocked"
)

Variables

This section is empty.

Functions

func LoggerMiddleware

func LoggerMiddleware(l *zap.Logger, next http.Handler) http.Handler

func NegotiateContentType

func NegotiateContentType(r *http.Request, offers []string, defaultOffer string) string

NegotiateContentType negotiates the content types based on the given request data (with possible Accept Header) and offered by http server (e.g. present for mocking) media types.

func NewHTTPServer

func NewHTTPServer(log *zap.Logger, mainHandler *mainHandler) *httpServer

func NewMainHandler

func NewMainHandler() *mainHandler

Types

type AcceptRange

type AcceptRange struct {
	Type       string
	Subtype    string
	Weight     float64
	Parameters map[string]string
	// contains filtered or unexported fields
}

AcceptRange represents an accept range as defined in https://tools.ietf.org/html/rfc7231#section-5.3.2

Accept = #( media-range [ accept-params ] )

media-range    = ( "*/*"
                 / ( type "/" "*" )
                 / ( type "/" subtype )
                 ) *( OWS ";" OWS parameter )
accept-params  = weight *( accept-ext )
accept-ext = OWS ";" OWS token [ "=" ( token / quoted-string ) ]

func AcceptMediaTypes

func AcceptMediaTypes(r *http.Request) []AcceptRange

AcceptMediaTypes builds a list of AcceptRange from the given HTTP request.

func ParseAcceptRange

func ParseAcceptRange(accept string) AcceptRange

ParseAcceptRange parses a single accept string into an AcceptRange.

func ParseAcceptRanges

func ParseAcceptRanges(accepts string) []AcceptRange

ParseAcceptRanges parses an Accept header into a list of AcceptRange

func (AcceptRange) RawString

func (a AcceptRange) RawString() string

RawString returns the raw string in the request specifying the accept range.

Jump to

Keyboard shortcuts

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