httpx

package module
v0.0.0-...-3cd9bcf Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 8 Imported by: 2

README

Go Reference

ugent-library/httpx

Package httpx contains convenience HTTP helper functions.

Install

go get -u github.com/ugent-library/httpx

Documentation

Overview

Package httpx contains convenience HTTP helper functions.

Index

Constants

This section is empty.

Variables

View Source
var (
	MethodOverrideHeader = "X-HTTP-Method-Override"
	MethodOverrideField  = "_method"
)
View Source
var (
	JSONContentType = "application/json"
)

Functions

func BasicAuth

func BasicAuth(username, password string) func(http.Handler) http.Handler

BasicAuth provides safe basic auth handling. See https://www.alexedwards.net/blog/basic-authentication-in-go.

func HasContentType

func HasContentType(r *http.Request, mimetypes ...string) bool

func MethodOverride

func MethodOverride(h http.Handler) http.Handler

The MethodOverride middleware checks for a HTTP method override in the request and uses it instead of the original method.

For security reasons only `POST` can be overridden with `PUT`, `PATCH` or `DELETE`.

MethodOverride is similar to the gorilla HTTPMethodOverrideHandler but checks for a X-HTTP-Method-Override header before the _method form field to avoid parsing the request body unnecessarily.

func RenderJSON

func RenderJSON(w http.ResponseWriter, status int, v any)

Types

This section is empty.

Jump to

Keyboard shortcuts

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