handlers

package
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseHandler

func BaseHandler[Req any, Resp any, Handler HandlerInterface[Req, Resp]](
	core requestCore.RequestCoreInterface,
	handler Handler,
	args ...any,
) any

func Dml

func Dml[Req libQuery.DmlModel](
	title, key string,
	core requestCore.RequestCoreInterface,
) any

func DmlHandler

func DmlHandler[Req libQuery.DmlModel](
	title, key, path string,
	core requestCore.RequestCoreInterface,
	mode libRequest.Type,
	validateHeader bool,
) any

func DmlHandlerOld added in v0.9.2

func DmlHandlerOld[Req libQuery.DmlModel](
	title, key string,
	core requestCore.RequestCoreInterface,
	mode libRequest.Type,
	validateHeader bool,
) any

func FinalizeDML

func FinalizeDML(request libQuery.DmlModel, key, title string, w webFramework.WebFramework, core requestCore.RequestCoreInterface)

Types

type DmlHandlerType

type DmlHandlerType[Req libQuery.DmlModel, Resp map[string]any] struct {
	Title        string
	Path         string
	Mode         libRequest.Type
	VerifyHeader bool
	Key          string
}

func (DmlHandlerType[Req, Resp]) Finalizer

func (h DmlHandlerType[Req, Resp]) Finalizer(req HandlerRequest[Req, Resp])

func (DmlHandlerType[Req, Resp]) Handler

func (h DmlHandlerType[Req, Resp]) Handler(req HandlerRequest[Req, Resp]) (Resp, response.ErrorState)

func (DmlHandlerType[Req, Resp]) Initializer

func (h DmlHandlerType[Req, Resp]) Initializer(req HandlerRequest[Req, Resp]) response.ErrorState

func (DmlHandlerType[Req, Resp]) Parameters

func (h DmlHandlerType[Req, Resp]) Parameters() (string, libRequest.Type, bool, bool, string)

type HandlerInterface

type HandlerInterface[Req any, Resp any] interface {
	// returns handler title
	//   Request Bodymode
	//   and validate header option
	//   and save to request table option
	//   and url path of handler
	Parameters() (string, libRequest.Type, bool, bool, string)
	// runs after validating request
	Initializer(req HandlerRequest[Req, Resp]) response.ErrorState
	// main handler runs after initialize
	Handler(req HandlerRequest[Req, Resp]) (Resp, response.ErrorState)
	// runs after sending back response
	Finalizer(req HandlerRequest[Req, Resp])
}

type HandlerRequest

type HandlerRequest[Req any, Resp any] struct {
	Title    string
	Core     requestCore.RequestCoreInterface
	Header   *libRequest.RequestHeader
	Request  *Req
	Response Resp
	W        webFramework.WebFramework
	Args     []any
}

Jump to

Keyboard shortcuts

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