http

package
v1.13.5 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: Apache-2.0 Imports: 13 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultHTTPClient = &http.Client{
	Timeout: 30 * time.Second,
}

Functions

func ConcatenateJSON

func ConcatenateJSON(first, second []byte) ([]byte, error)

func FormRequest

func FormRequest(endpoint string, request interface{}, encoder Encoder, authFn interface{}) (*http.Request, error)

func HttpRequest

func HttpRequest(client *http.Client, req *http.Request, response interface{}) error

func MarshalJSON

func MarshalJSON(w http.ResponseWriter, i interface{})

func MarshalJSONWithStatus

func MarshalJSONWithStatus(w http.ResponseWriter, i interface{}, status int)

func StartServer

func StartServer(ctx context.Context, port string)

func URLEncodeParams added in v1.5.1

func URLEncodeParams(resp interface{}, encoder Encoder) (url.Values, error)

Types

type CookieHandler

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

func NewCookieHandler

func NewCookieHandler(hashKey, encryptKey []byte, opts ...CookieHandlerOpt) *CookieHandler

func (*CookieHandler) CheckCookie

func (c *CookieHandler) CheckCookie(r *http.Request, name string) (string, error)

func (*CookieHandler) CheckQueryCookie

func (c *CookieHandler) CheckQueryCookie(r *http.Request, name string) (string, error)

func (*CookieHandler) DeleteCookie

func (c *CookieHandler) DeleteCookie(w http.ResponseWriter, name string)

func (*CookieHandler) SetCookie

func (c *CookieHandler) SetCookie(w http.ResponseWriter, name, value string) error

type CookieHandlerOpt

type CookieHandlerOpt func(*CookieHandler)

func WithDomain

func WithDomain(domain string) CookieHandlerOpt

func WithMaxAge

func WithMaxAge(maxAge int) CookieHandlerOpt

func WithPath added in v1.9.0

func WithPath(path string) CookieHandlerOpt

func WithSameSite

func WithSameSite(sameSite http.SameSite) CookieHandlerOpt

func WithUnsecure

func WithUnsecure() CookieHandlerOpt

type Decoder

type Decoder interface {
	Decode(dst interface{}, src map[string][]string) error
}

type Encoder

type Encoder interface {
	Encode(src interface{}, dst map[string][]string) error
}

type FormAuthorization

type FormAuthorization func(url.Values)

type RequestAuthorization

type RequestAuthorization func(*http.Request)

func AuthorizeBasic

func AuthorizeBasic(user, password string) RequestAuthorization

Jump to

Keyboard shortcuts

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