httputil

package
v0.0.0-...-1fa5987 Latest Latest
Warning

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

Go to latest
Published: May 14, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandlerWithContext

func HandlerWithContext(ctx context.Context, handler http.Handler) http.Handler

TODO: Refactor this in to multiple middlewares.

func WriteError

func WriteError(w http.ResponseWriter, req *http.Request, err error)

func WriteJSON

func WriteJSON(w http.ResponseWriter, req *http.Request, status int, v any)

func WriteString

func WriteString(w http.ResponseWriter, status int, s string)

Types

type HostAllowListHandler

type HostAllowListHandler struct {
	Hosts []string
	Next  http.Handler
}

HostAllowListHandler is an http handler designed to guard against DNS rebinding by rejecting requests that do not come with a whitelisted Host header.

func (*HostAllowListHandler) ServeHTTP

func (h *HostAllowListHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

type SSEWriter

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

https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events

func StartSSE

func StartSSE(w http.ResponseWriter) *SSEWriter

func (*SSEWriter) KeepAlive

func (w *SSEWriter) KeepAlive()

func (*SSEWriter) SendEvent

func (w *SSEWriter) SendEvent(typ string, data []byte)

Type and data may not contain newlines.

Jump to

Keyboard shortcuts

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