http

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnexpected = apperr.New("unexpected_error") // Error returned when an infrastructure error occurs

Functions

func Bind

func Bind[TIn any](s Server, handler func(*gin.Context, TIn) error) gin.HandlerFunc

Bind the request to the given TIn and handle errors if any by setting the appropriate status.

func Created

func Created[TOut any](s Server, ctx *gin.Context, data TOut, location string, args ...any) error

Sets the location header and the response status

func File

func File(ctx *gin.Context, filepath string) error

Returns the file at the given path.

func HandleError added in v1.1.0

func HandleError(s Server, ctx *gin.Context, err error)

Handle the given non-nil error and sets the status code based on error type.

func NoContent

func NoContent(ctx *gin.Context) error

Mark the request has succeeded with no data.

func Ok

func Ok[TOut any](ctx *gin.Context, data TOut) error

Mark the request has succeeded with the given data.

func Send

func Send(s Server, handler func(*gin.Context) error) gin.HandlerFunc

Call the given handler and handle any returned error by setting the appropriate status.

Types

type Server

type Server interface {
	IsSecure() bool
	Logger() log.Logger
}

Tiny interface to represents needed contrat in order to use helpers provided by this package.

Jump to

Keyboard shortcuts

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