hxxp

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Listen

func Listen(h *Handler) error

Listen opens and serves an HTTP handler.

func NewContext

func NewContext(ctx context.Context, log shared.Logger, address string, origin string, rate float64, burst int, ttl time.Duration, out string, prefix string) (context.Context, error)

NewContext is the utility to encapsulate pkg-scoped context values by preventing context key collision.

Types

type Handler

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

Handler is the application HTTP handler.

func New

func New(ctx context.Context) (handler *Handler, err error)

New constructs a new Handler.

func (Handler) Abort

func (h Handler) Abort(w http.ResponseWriter, message string, code int)

Abort is a helper to respond HTTP requests with errors.

func (Handler) Error

func (h Handler) Error(w http.ResponseWriter, err error, code int)

Error is a helper to abort HTTP requests with errors.

func (Handler) JSON

func (h Handler) JSON(data io.ReadCloser, result interface{}) error

JSON is a helper to encode data in JSON format.

func (Handler) Respond

func (h Handler) Respond(w http.ResponseWriter, message string, data interface{})

Respond is a helper to respond HTTP requests.

func (Handler) ServeHTTP

func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves HTTP requests.

func (Handler) Static

func (h Handler) Static(path string) string

Static is a helper to serve static files.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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