Documentation
¶
Index ¶
- func ContainsString(s []string, e string) bool
- 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
- type BasePathContext
- type ContextHelper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainsString ¶
func HalAddCuries ¶
func HalAddCuries(ch *ContextHelper, links *hal.HalRscLinks) *hal.HalRscLinks
func HalDocLink ¶
func HalDocLink(links *hal.HalRscLinks, operationId string) *hal.HalRscLinks
func HalRootRscLinks ¶
func HalRootRscLinks(ch *ContextHelper) (links *hal.HalRscLinks)
func HalSelfLink ¶
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
Click to show internal directories.
Click to hide internal directories.