httputil

package
v0.0.38 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MethodGET = "GET"
)

Common HTTP methods and header values

Variables

This section is empty.

Functions

func RespondWithError

func RespondWithError(w http.ResponseWriter, code int, err error)

RespondWithError provides an auxiliary function to handle all failed HTTP requests.

func RespondWithJSON

func RespondWithJSON(w http.ResponseWriter, code int, payload interface{})

RespondWithJSON provides an auxiliary function to return an HTTP response with JSON content and an HTTP status code.

Types

type ErrResponse

type ErrResponse struct {
	Error string `json:"error"`
}

ErrResponse defines an HTTP error response.

Jump to

Keyboard shortcuts

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