httpx

package module
v0.0.0-...-8e33440 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2022 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BeforeHTTPFunc

func BeforeHTTPFunc(ctx context.Context, req *http.Request) context.Context

BeforeHTTPFunc adds metadata into context

func EncodeHTTPResponse

func EncodeHTTPResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error

EncodeHTTPResponse writes the error from response if the response is a type of endpoint.Failer or returns the json encoded error

func ReadRemoteIP

func ReadRemoteIP(r *http.Request) string

ReadRemoteIP tries to find the public address ip from the http header

Types

type Link struct {
	URL    *url.URL
	URLRaw string
	Rel    string
	Params map[string]string
}

A Link is a single URL and related parameters

func (Link) HasParam

func (l Link) HasParam(key string) bool

HasParam returns if a Link has a particular parameter or not

func (Link) Param

func (l Link) Param(key string) string

Param returns the value of a parameter if it exists

func (Link) String

func (l Link) String() string

String returns the string representation of a link

type Links []Link

Links is a slice of Link structs

func Parse

func Parse(raw string) Links

Parse parses a raw Link header in the form:

<url>; rel="foo", <url>; rel="bar"; wat="dis"

returning a slice of Link structs

func ParseMultiple

func ParseMultiple(headers []string) Links

ParseMultiple is like Parse, but accepts a slice of headers rather than just one header string

func (Links) FilterByRel

func (l Links) FilterByRel(r string) Links

FilterByRel filters a group of Links by the provided Rel attribute

func (Links) String

func (l Links) String() string

String returns the string representation of multiple Links for use in HTTP responses etc

Jump to

Keyboard shortcuts

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