response

package
v0.84.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClientRedirectHeader        = "X-Client-Redirect"
	ClientAcceptsRedirectHeader = "X-Accepts-Client-Redirect"
)

Variables

This section is empty.

Functions

func GetClientRedirectURL

func GetClientRedirectURL(w http.ResponseWriter) string

Types

type Proxy

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

Do not instantiate directly. Use NewProxy().

func MergeProxyResponses

func MergeProxyResponses(proxies ...*Proxy) *Proxy

Consumers should deduplicate head els after calling MergeProxyResponses by using headels.ToHeadEls(proxy.GetHeadElements())

func NewProxy

func NewProxy() *Proxy

func (*Proxy) AddHeadEls added in v0.83.0

func (p *Proxy) AddHeadEls(els *headels.HeadEls)

func (*Proxy) AddHeader

func (p *Proxy) AddHeader(key, value string)

func (*Proxy) ApplyToResponseWriter

func (p *Proxy) ApplyToResponseWriter(w http.ResponseWriter, r *http.Request)

func (*Proxy) GetCookies

func (p *Proxy) GetCookies() []*http.Cookie

func (*Proxy) GetHeadEls added in v0.83.0

func (p *Proxy) GetHeadEls() *headels.HeadEls

func (*Proxy) GetHeader

func (p *Proxy) GetHeader(key string) string

func (*Proxy) GetHeaders

func (p *Proxy) GetHeaders(key string) []string

func (*Proxy) GetLocation

func (p *Proxy) GetLocation() string

func (*Proxy) GetStatus

func (p *Proxy) GetStatus() (int, string)

func (*Proxy) IsError

func (p *Proxy) IsError() bool

func (*Proxy) IsRedirect

func (p *Proxy) IsRedirect() bool

func (*Proxy) IsSuccess

func (p *Proxy) IsSuccess() bool

func (*Proxy) Redirect

func (p *Proxy) Redirect(r *http.Request, url string, code ...int) bool

bool return value indicates whether the redirect upgraded to a client redirect

func (*Proxy) SetCookie

func (p *Proxy) SetCookie(cookie *http.Cookie)

func (*Proxy) SetHeader

func (p *Proxy) SetHeader(key, value string)

func (*Proxy) SetStatus

func (p *Proxy) SetStatus(status int, errorStatusText ...string)

type Response

type Response struct {
	Writer http.ResponseWriter
	// contains filtered or unexported fields
}

func New

func (*Response) AddHeader

func (res *Response) AddHeader(key, value string)

func (*Response) BadRequest

func (res *Response) BadRequest(reasons ...string)

func (*Response) ClientRedirect

func (res *Response) ClientRedirect(url string) error

sets status to 200 if not already set

func (*Response) Error

func (res *Response) Error(status int, reasons ...string)

func (*Response) Forbidden

func (res *Response) Forbidden(reasons ...string)

func (*Response) HTML

func (res *Response) HTML(html string)

func (*Response) HTMLBytes

func (res *Response) HTMLBytes(bytes []byte)

func (*Response) InternalServerError

func (res *Response) InternalServerError(reasons ...string)

func (*Response) IsCommitted

func (res *Response) IsCommitted() bool

func (*Response) JSON

func (res *Response) JSON(v any)

Pass in non-encoded JSON-marshallable data

func (*Response) JSONBytes

func (res *Response) JSONBytes(bytes []byte)

Pass in pre-encoded JSON bytes

func (*Response) MethodNotAllowed

func (res *Response) MethodNotAllowed(reasons ...string)

func (*Response) NotFound

func (res *Response) NotFound()

func (*Response) NotModified

func (res *Response) NotModified()

func (*Response) OK

func (res *Response) OK()

Returns a 200 JSON response of {"ok":true}

func (*Response) OKText

func (res *Response) OKText()

Returns a 200 text response of "OK"

func (*Response) Redirect

func (res *Response) Redirect(r *http.Request, url string, code ...int) (usedClientRedirect bool, err error)

func (*Response) ServerRedirect

func (res *Response) ServerRedirect(r *http.Request, url string, code ...int)

func (*Response) SetHeader

func (res *Response) SetHeader(key, value string)

func (*Response) SetStatus

func (res *Response) SetStatus(status int)

func (*Response) Text

func (res *Response) Text(text string)

func (*Response) TooManyRequests

func (res *Response) TooManyRequests(reasons ...string)

func (*Response) Unauthorized

func (res *Response) Unauthorized(reasons ...string)

Jump to

Keyboard shortcuts

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