handlers

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DcdrScopesHeader comma delimited scopes to pass to the client
	DcdrScopesHeader = "x-dcdr-scopes"
	// ContentTypeHeader header for content type
	ContentTypeHeader = "Content-Type"
	// ContentType set JSON content type for responses
	ContentType = "application/json"
	// MaxScopeLimit the maximum amount of scopes allowed
	MaxScopeLimit = 8
)

Variables

This section is empty.

Functions

func AppendScope added in v0.3.0

func AppendScope(r *http.Request, scope string)

AppendScope adds a scope to the `x-dcdr-scopes` header

func FeaturesHandler

func FeaturesHandler(c client.IFace) func(
	w http.ResponseWriter, r *http.Request)

FeaturesHandler default handler for serving a FeatureMap via HTTP

func GetScopes

func GetScopes(r *http.Request) []string

GetScopes parses the comma delimited string from DcdrScopesHeader into a slice of strings.

x-dcdr-scopes: "a/b/c, d" => []string{"a/b/c", "d"}

func ScopeMapFromRequest

func ScopeMapFromRequest(c client.IFace, r *http.Request) *models.FeatureMap

ScopeMapFromRequest helper method for returning a FeatureMap scoped to the values found in DcdrScopesHeader.

func SetResponseHeaders

func SetResponseHeaders(w http.ResponseWriter, r *http.Request)

SetResponseHeaders set the common response headers

func SetScopes added in v0.3.0

func SetScopes(r *http.Request, scopes []string)

SetScopes joins the values from scopes and sets the scopes header

Types

This section is empty.

Jump to

Keyboard shortcuts

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