rest

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const RequestObjectContextKey = "service_requestObject"

Variables

This section is empty.

Functions

func Get

func Get[RES any](ctx context.Context, requestId string, url string, heades map[string]string) (*RES, error)

func Patch

func Patch[RES any](ctx context.Context, requestId string, url string, heades map[string]string, body any) (*RES, error)

func Post

func Post[RES any](ctx context.Context, requestId string, url string, heades map[string]string, body any) (*RES, error)

func Put

func Put[RES any](ctx context.Context, requestId string, url string, heades map[string]string, body any) (*RES, error)

func RestLogFieldExtractor

func RestLogFieldExtractor(c echo.Context) []zapcore.Field

func Wrapper

func Wrapper[TREQ any](wrapped func(context.Context, *TREQ) (*Result, error)) echo.HandlerFunc

Types

type Delegate

type Delegate[REQ any] func(*logger.Logger, context.Context, *REQ) (*Result, error)

type GenericResult

type GenericResult[T any] struct {
	RequestId  string      `json:"requestId,omitempty"`
	Data       T           `json:"data"`
	Pagination *Pagination `json:"pagination,omitempty"`
}

type Pagination

type Pagination struct {
	Total int `json:"total"`
}

type PaginationReq

type PaginationReq struct {
	// Limit number of resource in the response
	Limit int64 `json:"limit" query:"limit" extensions:"x-order=101" example:"200"`
	// Offset number of resource in the response
	Offset int64 `json:"offset" query:"offset" extensions:"x-order=102" example:"0"`
}

type Result

type Result struct {
	RequestId  string      `json:"requestId,omitempty"`
	Data       any         `json:"data"`
	Pagination *Pagination `json:"pagination,omitempty"`
}

func Call

func Call[REQ any](e context.Context, req *REQ, name string, delegate Delegate[REQ]) (*Result, error)

Jump to

Keyboard shortcuts

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