http

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package http includes handlers and utilties

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasicAuthMiddleware

func BasicAuthMiddleware(next http.Handler, username, password, realm string) http.HandlerFunc

BasicAuthMiddleware is a simple HTTP plain authentication middleware.

func ReadAllAndReplaceBody

func ReadAllAndReplaceBody(r *http.Request) ([]byte, error)

ReadAllAndReplaceBody reads all of r.Body and replaces it with a new byte buffer.

func TraceLoggingMiddleware

func TraceLoggingMiddleware(next http.Handler, logger log.Logger, newTrace func() string) http.HandlerFunc

TraceLoggingMiddleware sets up a trace ID in the request context and logs HTTP requests.

func VersionHandler

func VersionHandler(version string) http.HandlerFunc

VersionHandler returns a simple JSON response from a version string.

Types

type MethodMux

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

MethodMux is an HTTP request multiplexer. It matches the HTTP method of each incoming request against a list of registered HTTP method names and calls the handler that matches.

func NewMethodMux

func NewMethodMux() *MethodMux

NewMethodMux creates a new MethodMux.

func (*MethodMux) Handle

func (mux *MethodMux) Handle(method string, handler http.Handler)

Handle registers the handler for the given method. If handler already exists for the given method, Handle panics.

func (*MethodMux) ServeHTTP

func (mux *MethodMux) ServeHTTP(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis
Package api implements HTTP handlers for the NanoDEP API.
Package api implements HTTP handlers for the NanoDEP API.

Jump to

Keyboard shortcuts

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