httputil

package
v0.30.2 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2022 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindData

func BindData(c *gin.Context, data interface{}) error

BindData binds the data from the request to the struct passed in the interface.

func ErrorHandler added in v0.30.2

func ErrorHandler(c *gin.Context, err error)

ErrorHandler handles errors for fetching data from the database.

func ErrorInvalidQueryString added in v0.26.0

func ErrorInvalidQueryString(c *gin.Context)

func ErrorInvalidUUID

func ErrorInvalidUUID(c *gin.Context)

func GetBodyFields added in v0.30.2

func GetBodyFields(c *gin.Context, resource any) ([]any, error)

GetBodyFields returns a slice of strings with the field names of the resource passed in. Only names of fields which are set in the body are contained in that slice.

This function reads and copies the reuqest body, it must always be called before any of gin's c.*Bind methods.

func GetURLFields added in v0.30.2

func GetURLFields(url *url.URL, filter any) []any

func NewError

func NewError(c *gin.Context, status int, err error)

NewError creates an HTTPError instance and returns it.

func OptionsGet

func OptionsGet(c *gin.Context)

func OptionsGetPatchDelete

func OptionsGetPatchDelete(c *gin.Context)

func OptionsGetPost

func OptionsGetPost(c *gin.Context)

func RequestHost

func RequestHost(c *gin.Context) string

The scheme defaults to https and only falls back to http if the x-forwarded-proto header is set to "http".

func RequestPathV1

func RequestPathV1(c *gin.Context) string

RequestPathV1 returns the URL with the prefix for API v1.

func RequestURL

func RequestURL(c *gin.Context) string

RequestURL returns the full request URL.

func UUIDFromString added in v0.26.0

func UUIDFromString(c *gin.Context, s string) (uuid.UUID, error)

This is needed because gin does not support form binding to uuid.UUID currently. Follow https://github.com/gin-gonic/gin/pull/3045 to see when this gets resolved.

Types

type HTTPError

type HTTPError struct {
	Error string `json:"error" example:"An ID specified in the query string was not a valid uint64"`
}

HTTPError is used for error responses that contain a body.

Jump to

Keyboard shortcuts

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