urlbuilder

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: Apache-2.0 Imports: 7 Imported by: 9

Documentation

Index

Constants

View Source
const (
	PrefixHeader           = "X-API-URL-Prefix"
	ForwardedAPIHostHeader = "X-API-Host"
	ForwardedHostHeader    = "X-Forwarded-Host"
	ForwardedProtoHeader   = "X-Forwarded-Proto"
	ForwardedPortHeader    = "X-Forwarded-Port"
)

Variables

This section is empty.

Functions

func ConstructBasicURL

func ConstructBasicURL(parts ...string) string

func GetHost

func GetHost(r *http.Request, scheme string) string

func GetScheme

func GetScheme(r *http.Request) string

func New

func New(r *http.Request, resolver PathResolver, schemas *types.APISchemas) (types.URLBuilder, error)

func NewPrefixed

func NewPrefixed(r *http.Request, schemas *types.APISchemas, prefix string) (types.URLBuilder, error)

func ParseRequestURL

func ParseRequestURL(r *http.Request) string

func ParseResponseURLBase

func ParseResponseURLBase(currentURL string, r *http.Request) (string, error)

func RedirectRewrite

func RedirectRewrite(next http.Handler) http.Handler

Types

type DefaultPathResolver

type DefaultPathResolver struct {
	Prefix string
}

func (*DefaultPathResolver) Schema

func (d *DefaultPathResolver) Schema(base string, schema *types.APISchema) string

type DefaultURLBuilder

type DefaultURLBuilder struct {
	// contains filtered or unexported fields
}

func (*DefaultURLBuilder) Action

func (u *DefaultURLBuilder) Action(schema *types.APISchema, id, action string) string

func (*DefaultURLBuilder) Collection

func (u *DefaultURLBuilder) Collection(schema *types.APISchema) string

func (*DefaultURLBuilder) CollectionAction

func (u *DefaultURLBuilder) CollectionAction(schema *types.APISchema, action string) string

func (*DefaultURLBuilder) Current

func (u *DefaultURLBuilder) Current() string
func (u *DefaultURLBuilder) Link(schema *types.APISchema, id string, linkName string) string

func (*DefaultURLBuilder) Marker

func (u *DefaultURLBuilder) Marker(marker string) string

func (*DefaultURLBuilder) RelativeToRoot

func (u *DefaultURLBuilder) RelativeToRoot(path string) string
func (u *DefaultURLBuilder) ResourceLink(schema *types.APISchema, id string) string

type PathResolver

type PathResolver interface {
	Schema(base string, schema *types.APISchema) string
}

Jump to

Keyboard shortcuts

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