utils

package
v0.0.0-...-f80c191 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Validate = validator.New()

Validate acts a single, cached validator across the app.

Functions

func GetTokenFromRequest

func GetTokenFromRequest(r *http.Request) string

func ParseJson

func ParseJson(r *http.Request, payload any) error

ParseJson decodes the request body into the payload.

func WriteError

func WriteError(w http.ResponseWriter, status HttpStatus, err error)

WriteError writes a HTTP error as a JSON response.

func WriteJson

func WriteJson(w http.ResponseWriter, status HttpStatus, payload any) error

WriteJson writes the payload as a JSON response.

Types

type HttpStatus

type HttpStatus int

Jump to

Keyboard shortcuts

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