utils

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func QueryMapToVal

func QueryMapToVal(query url.Values, val any) error

QueryMapToVal implements an all-in-one decoder to decode requests' query parameters to structured value.

func WrapTypeAny

WrapTypeAny implements a wrap function for variables with type Any to become UnpackInterfacesMessage, which is meant to unpack values packed within Any's using the AnyUnpacker.

Types

type AutoSimpleInterfaceWrapFunc

type AutoSimpleInterfaceWrapFunc[T any] func(typ *T, r *http.Request) (resp any, err error)

type HTTPError

type HTTPError struct {
	// contains filtered or unexported fields
}

func NewHTTPError

func NewHTTPError(errorCode uint32, err string) *HTTPError

func WrapHTTPError

func WrapHTTPError(err error) *HTTPError

func WrapHTTPErrorWithCode

func WrapHTTPErrorWithCode(errorCode uint32, err error) *HTTPError

func (HTTPError) Unwrap

func (e HTTPError) Unwrap() error

type RespFunc

type RespFunc func(w http.ResponseWriter, r *http.Request)

func AutoWrap

func AutoWrap[T any](codec *codec.LegacyAmino, api AutoSimpleInterfaceWrapFunc[T]) RespFunc

AutoWrap implements a response encoder for requests with query paramenters.

func SimpleWrap

func SimpleWrap(codec *codec.LegacyAmino, api SimpleWrapFunc) RespFunc

SimpleWrap implements a response encoder for requests without any query paramenter.

type Response

type Response struct {
	Code  int             `json:"code"`
	Msg   json.RawMessage `json:"msg"`
	Error string          `json:"error"`
}

type SimpleWrapFunc

type SimpleWrapFunc func(r *http.Request) (resp any, err error)

Jump to

Keyboard shortcuts

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