routerHelper

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsValueInSlice

func ContainsValueInSlice(slice []string, value string) bool

func DefaultUrlParamWrapper

func DefaultUrlParamWrapper(name string) string

func DishUrlAndMethod

func DishUrlAndMethod(dish kitchen.IDish, urlParamWrapper func(string) string) (url string, urlParams [][2]string, method string, webUrlParamMap []int)

func ParseRequestToInput

func ParseRequestToInput(input any, bundle kitchen.IWebBundle, webUrlParamMap []int, isWebInput bool) (processedInput any, raw []byte, err error)

func Ternary

func Ternary[T any](condition bool, trueVal, falseVal T) T

func WebReturn

func WebReturn(a kitchen.IDish, w http.ResponseWriter, outputAny any, err error)

Types

type DefaultWebBundle

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

func NewDefaultWebBundle

func NewDefaultWebBundle(request *http.Request, response http.ResponseWriter) DefaultWebBundle

func (DefaultWebBundle) Body

func (d DefaultWebBundle) Body() ([]byte, error)

func (DefaultWebBundle) Ctx

func (DefaultWebBundle) Headers

func (d DefaultWebBundle) Headers() http.Header

func (DefaultWebBundle) Method

func (d DefaultWebBundle) Method() string

func (DefaultWebBundle) Raw

func (d DefaultWebBundle) Raw() any

func (DefaultWebBundle) Response

func (d DefaultWebBundle) Response() http.ResponseWriter

func (DefaultWebBundle) Url

func (d DefaultWebBundle) Url() *url.URL

func (DefaultWebBundle) UrlParams

func (d DefaultWebBundle) UrlParams() map[string]string

type IWebCookware

type IWebCookware interface {
	kitchen.ICookware
	RequestParser(action kitchen.IDish, bundle kitchen.IWebBundle) (IWebCookware, error) //parse user, permission
}

IWebCookware is an interface for cookware that can be parsed from web request

type IWebParsableInput

type IWebParsableInput interface {
	ParseRequestToInput(kitchen.IWebBundle) (raw []byte, err error)
}

IWebParsableInput is an interface for cooker input enable parsing web request to input

type IWebWrapper

type IWebWrapper interface {
	FormatUrlParam(name string) string
	AddMenuToRouter(instance kitchen.IInstance, prefix ...string)
}

IWebWrapper is an interface for web router wrapper

type WebErr

type WebErr struct {
	Err        error
	HttpStatus int
	Extra      map[string]string
	ErrorCode  int32
}

func (WebErr) Error

func (w WebErr) Error() string

type WebWriter

type WebWriter struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

func (*WebWriter) Write

func (w *WebWriter) Write(data []byte) (int, error)

func (*WebWriter) WriteHeader

func (w *WebWriter) WriteHeader(statusCode int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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