helpers

package
v0.0.0-...-3fd5aad Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsString

func ContainsString(s []string, e string) bool

func HalAddCuries

func HalAddCuries(ch *ContextHelper, links *hal.HalRscLinks) *hal.HalRscLinks
func HalDocLink(links *hal.HalRscLinks, operationId string) *hal.HalRscLinks
func HalRootRscLinks(ch *ContextHelper) (links *hal.HalRscLinks)
func HalSelfLink(links *hal.HalRscLinks, href string) *hal.HalRscLinks

Types

type BasePathContext

type BasePathContext interface {
	BasePath() string
	LookupRoute(*http.Request) (*middleware.MatchedRoute, bool)
}

type ContextHelper

type ContextHelper struct {
	Request          *http.Request
	ServerURL        string
	Endpoint         string
	EndpointSingular string
	FQEndpoint       string
	OperationID      string
	BasePath         string
	PathParts        []string
	// contains filtered or unexported fields
}

ContextHelper is split into its own little function, as test it is really difficult due to the un-exported nature of the majority of the `MatchedRoute` struct, which means it's very difficult to generate a mock response to ctx.LookupRoute. Doing it this way, means we can mock it in tests.

func NewContextHelper

func NewContextHelper(ctx BasePathContext) (*ContextHelper, error)

NewContextHelper to easily get URL parts for generating HAL resources

func NewContextHelperWithContext

func NewContextHelperWithContext(ctx BasePathContext) (*ContextHelper, error)

func (*ContextHelper) ParseRequest

func (ch *ContextHelper) ParseRequest(host string, basePath string,
	requestUri string, hasTls bool)

func (*ContextHelper) SetRequest

func (ch *ContextHelper) SetRequest(req *http.Request) (err error)

SetRequest and calculate the api parts from the combination of the request and the API. This is used to generate HAL resources

func (*ContextHelper) WithBasePath

func (ch *ContextHelper) WithBasePath(basePath string) *ContextHelper

Jump to

Keyboard shortcuts

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