requestCore

package module
v0.10.21 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: GPL-3.0 Imports: 23 Imported by: 0

README

requestCore

Library for handling restful requests

Documentation

Index

Constants

View Source
const RegexPaddedIp string = `^((25[0-5]|2[0-4]\d|1\d\d|0\d\d)\.?\b){4}$` //^((25[0-5]|2[0-4]\d|1\d\d|0\d\d)\.?\b){4}$

Variables

View Source
var Validate *validator.Validate

Functions

func DeleteHandler

func DeleteHandler[Req webFramework.RecordData](title, delete, checkQuery string,
	core RequestCoreInterface,
	hasInitializer bool, parser webFramework.FieldParser,
) any

func GetAll

func GetAll[Model GetHandler](title string,
	core RequestCoreInterface,
	respHandler response.ResponseHandler,
	args ...any) any

func GetAllMapHandler

func GetAllMapHandler[Model MapHandler](title string,
	core RequestCoreInterface,
	respHandler response.ResponseHandler,
	args ...any) any

func GetMapBySubHandler

func GetMapBySubHandler[Req any, Resp webFramework.RecordData](title, sql string,
	core RequestCoreInterface,
	hasParam bool) any

func GetMapHandler

func GetMapHandler[Req any, Resp webFramework.RecordData](title, sql string,
	core RequestCoreInterface,
	hasParam bool) any

func GetPage

func GetPage[Model GetPageHandler](title string,
	core RequestCoreInterface,
	respHandler response.ResponseHandler,
	args ...any) any

func GetParams added in v0.4.18

func GetParams(w webFramework.WebFramework, args ...any) map[string]string

func GetQuery

func GetQuery[Req any](title, sql string,
	core RequestCoreInterface,
	hasParam bool) any

func GetQueryFillable

func GetQueryFillable[Resp libQuery.QueryWithDeps](
	title, query string,
	core RequestCoreInterface,
	args ...string,
) any

func GetQueryHandler

func GetQueryHandler[Req, Resp any](title, sql string,
	core RequestCoreInterface,
	args ...any) any

func GetQueryMap

func GetQueryMap[Req any](title, sql string,
	core RequestCoreInterface,
	hasParam bool) any

func GetSingleRecord

func GetSingleRecord[Model GetHandler](title string,
	core RequestCoreInterface,
	respHandler response.ResponseHandler,
	args ...any) any

func GetSingleRecordHandler

func GetSingleRecordHandler[Req, Resp any](title, sql string,
	core RequestCoreInterface,
) any

func Init

func Init() (ut.Translator, *validator.Validate, error)

func InitReqLog added in v0.3.18

func PaddedIpValidator

func PaddedIpValidator(fl validator.FieldLevel) bool

func PostHandler

func PostHandler[Req libQuery.RecordDataDml](title string,
	core RequestCoreInterface,
	hasInitializer bool,
	finalizer func(request Req, c any),
	args ...any,
) any

func PutHandler

func PutHandler[Req libQuery.RecordDataDml](title string,
	core RequestCoreInterface,
	hasInitializer bool,
	finalizer func(request Req, c any),
	args ...any,
) any

func QueryHandler added in v0.5.0

func QueryHandler[Req libQuery.QueryRequest, Resp libQuery.QueryResult](
	title, key string, queryMap map[string]libQuery.QueryCommand,
	core RequestCoreInterface,
	mode libRequest.Type,
	validateHeader bool,
) any

func Respond added in v0.7.0

func Respond(code, status int, message string, data any, abort bool, w webFramework.WebFramework)

func UpdateHandler

func UpdateHandler[Req libQuery.Updatable](title string, hasReqLog bool,
	core RequestCoreInterface,
	hasInitializer bool,
	finalizer func(request Req, c any),
	args ...string,
) any

Types

type Empty

type Empty struct {
}

type GetHandler

type GetHandler interface {
	GetSingle(
		core RequestCoreInterface, args map[string]string,
	) (any, string, error)
	GetAll(
		core RequestCoreInterface, args map[string]string,
	) (any, string, error)
}

type GetPageHandler

type GetPageHandler interface {
	GetPage(
		core RequestCoreInterface,
		pageSize, pageId int,
		args map[string]string,
	) (any, string, error)
	GetPageParams() (int, int)
}

type MapHandler

type MapHandler interface {
	GetAllMap(
		core RequestCoreInterface, args ...any,
	) (map[string]any, string, error)
}

type RequestCoreInterface

type RequestCoreInterface interface {
	GetDB() libQuery.QueryRunnerInterface
	RequestTools() libRequest.RequestInterface
	Consumer() libCallApi.CallApiInterface
	Responder() response.ResponseHandler
	Dictionary() libDictionary.DictionaryInterface
	Params() libParams.ParamsInterface
	Sm() libCrypto.Sm
}

type RequestCoreModel

type RequestCoreModel struct {
	RequestInterface   libRequest.RequestInterface
	QueryInterface     libQuery.QueryRunnerInterface
	RemoteApiInterface libCallApi.CallApiInterface
	RespHandler        response.ResponseHandler
	Dict               libDictionary.DictionaryInterface
	ParamMap           libParams.ParamsInterface
	CryptoSm           libCrypto.Sm
}

func (RequestCoreModel) Consumer

func (RequestCoreModel) Dictionary

func (RequestCoreModel) GetDB

func (RequestCoreModel) Params added in v0.4.15

func (RequestCoreModel) RequestTools

func (m RequestCoreModel) RequestTools() libRequest.RequestInterface

func (RequestCoreModel) Responder

func (RequestCoreModel) Sm added in v0.4.28

func (m RequestCoreModel) Sm() libCrypto.Sm

type WebHanlder added in v0.7.0

type WebHanlder struct {
	MessageDesc      map[string]string
	ErrorDesc        map[string]string
	RequestInterface libRequest.RequestInterface
}

func (WebHanlder) Error added in v0.9.0

func (WebHanlder) ErrorState added in v0.7.0

func (WebHanlder) GetErrorsArray added in v0.7.0

func (m WebHanlder) GetErrorsArray(message string, data any) []response.ErrorResponse

func (WebHanlder) HandleErrorState added in v0.7.0

func (m WebHanlder) HandleErrorState(err error, status int, message string, data any, w webFramework.WebFramework)

func (WebHanlder) OK added in v0.9.0

func (m WebHanlder) OK(w webFramework.WebFramework, resp any)

func (WebHanlder) OKWithAttachment added in v0.10.4

func (m WebHanlder) OKWithAttachment(w webFramework.WebFramework, attachment *response.FileResponse)

func (WebHanlder) OKWithReceipt added in v0.9.0

func (m WebHanlder) OKWithReceipt(w webFramework.WebFramework, resp any, receipt *response.Receipt)

func (WebHanlder) Respond added in v0.7.0

func (m WebHanlder) Respond(code, status int, message string, data any, abort bool, w webFramework.WebFramework)

func (WebHanlder) RespondWithAttachment added in v0.10.4

func (m WebHanlder) RespondWithAttachment(code, status int, message string, file *response.FileResponse, abort bool, w webFramework.WebFramework)

func (WebHanlder) RespondWithReceipt added in v0.7.0

func (m WebHanlder) RespondWithReceipt(code, status int, message string, data any, printData *response.Receipt, abort bool, w webFramework.WebFramework)

Directories

Path Synopsis
nolint:,staticcheck,ineffassign
nolint:,staticcheck,ineffassign

Jump to

Keyboard shortcuts

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