httpapi

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ForwardedHeader       = "Forwarded"
	XForwardedHostHeader  = "X-Forwarded-Host"
	XForwardedProtoHeader = "X-Forwarded-Proto"
)

Variables

This section is empty.

Functions

func RequestBaseURL

func RequestBaseURL(r *http.Request, basePath string) url.URL

RequestBaseURL returns the base URL of the request. It prioritizes forwarded proxy headers.

func Write

func Write(rw http.ResponseWriter, status int, response interface{})

Write outputs a standardized format to an HTTP response body.

func WriteBytes

func WriteBytes(rw http.ResponseWriter, status int, bytes []byte)

WriteBytes tries to write the provided bytes and errors if unable.

Types

type ErrorResponse

type ErrorResponse struct {
	Message   string    `json:"message"`
	Detail    string    `json:"detail"`
	RequestID uuid.UUID `json:"requestId,omitempty"`
}

type StatusWriter

type StatusWriter struct {
	http.ResponseWriter
	Status   int
	Hijacked bool
	// contains filtered or unexported fields
}

StatusWriter intercepts the status of the request and the response body up to maxBodySize if Status >= 400. It is guaranteed to be the ResponseWriter directly downstream from Middleware.

func (*StatusWriter) Hijack

func (w *StatusWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)

func (*StatusWriter) ResponseBody

func (w *StatusWriter) ResponseBody() []byte

func (*StatusWriter) Write

func (w *StatusWriter) Write(b []byte) (int, error)

func (*StatusWriter) WriteHeader

func (w *StatusWriter) WriteHeader(status int)

Jump to

Keyboard shortcuts

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