serdser

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package serdser contains the reusable serialization/deserialization logics in order to be used by the resource packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddErr

func AddErr(errs *map[string][]string, name string, msgs ...string)

AddErr adds the msgs error strings for the name field into the given errs map (instantiating it, if errs is nil yet).

func Assert

func Assert(errs *map[string][]string, ok bool, name string, msgs ...string) bool

Assert ensures that ok is true, and it was false, the name and msgs will be added to the errs map using the AddErr function.

func Bind

func Bind(c *gin.Context, req any, b binding.Binding) bool

Bind tries to bind the request parameters, from the c context, into the req struct, received as an interface.

The b indicates the binding method. Use binding.JSON in order to read json data from the body, binding.Query in order to read the URL query parameters, binding.Form in order to read a urlencoded or multipart form body for requests with a body and to read query parameters for GET requests, binding.Uri in order to read the path parameters.

func SerErr

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

SerErr serializes the err error and transmits it as a JSON object with "detail" field containing the err string representation. If err is a *cerr.Error object, its HTTPStatusCode will be used for transmission of the error. Otherwise, a 500 response will be sent.

Types

This section is empty.

Jump to

Keyboard shortcuts

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