dworkweb

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

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

func MakeApp

func MakeApp() App

func (*App) DELETE

func (app *App) DELETE(path string, handler func(ctx Context)) error

DELETE handles HTTP DELETE requests for the specified path.

func (*App) GET

func (app *App) GET(path string, handler func(ctx Context)) error

GET handles HTTP GET requests for the specified path.

func (*App) Group

func (app *App) Group(path string) Group

func (*App) HEAD

func (app *App) HEAD(path string, handler func(ctx Context)) error

HEAD handles HTTP HEAD requests for the specified path.

func (*App) OPTIONS

func (app *App) OPTIONS(path string, handler func(ctx Context)) error

OPTIONS handles HTTP OPTIONS requests for the specified path.

func (*App) PATCH

func (app *App) PATCH(path string, handler func(ctx Context)) error

PATCH handles HTTP PATCH requests for the specified path.

func (*App) POST

func (app *App) POST(path string, handler func(ctx Context)) error

POST handles HTTP POST requests for the specified path.

func (*App) PUT

func (app *App) PUT(path string, handler func(ctx Context)) error

PUT handles HTTP PUT requests for the specified path.

func (*App) Routes

func (app *App) Routes() *router.Routes

Routes returns the Router object of the App.

func (*App) Serve

func (app *App) Serve(port string)

Serve

type Context

type Context struct {
	Response CtxResponse
	Request  CtxRequest
}

type CtxRequest

type CtxRequest struct {
	Raw    *http.Request
	Params CtxRequestParams
}

func (*CtxRequest) Body

func (ctx *CtxRequest) Body() ([]byte, error)

Body returns the body data of the Request.

type CtxRequestParams

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

func (*CtxRequestParams) Bool

func (ctx *CtxRequestParams) Bool(param string) (bool, error)

Bool checks if the param exists and casts it to a bool.

Parameters:

- param: the name of the parameter to retrieve.

Return type:

- bool: the value of the parameter as a bool.

- error: an error of type ErrorParamNotFound if the parameter does not exist.

func (*CtxRequestParams) Float

func (ctx *CtxRequestParams) Float(param string) (float64, error)

Float checks if the param exists and casts it to a float.

Parameters:

- param: the name of the parameter to retrieve.

Return type:

- float64: the value of the parameter as a float.

- error: an error of type ErrorParamNotFound if the parameter does not exist.

func (*CtxRequestParams) Int

func (ctx *CtxRequestParams) Int(param string) (int, error)

Int checks if the param exists and casts it to an int.

Parameters:

- param: the name of the parameter to retrieve.

Return type:

- int: the value of the parameter as an int.

- error: an error of type ErrorParamNotFound if the parameter does not exist.

func (*CtxRequestParams) String

func (ctx *CtxRequestParams) String(param string) (string, error)

String returns the value of a specified parameter as a string.

Parameters:

- param: the name of the parameter to retrieve.

Return type:

- string: the value of the parameter as a string.

- error: an error of type ErrorParamNotFound if the parameter does not exist.

func (*CtxRequestParams) UUID

func (ctx *CtxRequestParams) UUID(param string) (string, error)

UUID checks if the param exists and casts it to a uuid.

Parameters:

- param: the name of the parameter to retrieve.

Return type:

- string: the value of the parameter as a uuid.

- error: an error of type ErrorParamNotFound if the parameter does not exist.

type CtxResponse

type CtxResponse struct {
	Raw *http.ResponseWriter
}

func (*CtxResponse) Html

func (ctx *CtxResponse) Html(data string)

func (*CtxResponse) Json

func (ctx *CtxResponse) Json(data interface{})

func (*CtxResponse) Status

func (ctx *CtxResponse) Status(code types.StatusCode)

func (*CtxResponse) Text

func (ctx *CtxResponse) Text(data string)

type ErrorParamNotFound

type ErrorParamNotFound struct {
	Param string
}

func (ErrorParamNotFound) Error

func (err ErrorParamNotFound) Error() string

type ErrorParamNotIsT

type ErrorParamNotIsT struct {
	Param string
	Type  string
}

func (ErrorParamNotIsT) Error

func (err ErrorParamNotIsT) Error() string

type Group

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

func (*Group) DELETE

func (g *Group) DELETE(path string, handler func(ctx Context)) error

func (*Group) GET

func (g *Group) GET(path string, handler func(ctx Context)) error

func (*Group) Group

func (g *Group) Group(path string) Group

func (*Group) HEAD

func (g *Group) HEAD(path string, handler func(ctx Context)) error

func (*Group) OPTIONS

func (g *Group) OPTIONS(path string, handler func(ctx Context)) error

func (*Group) PATCH

func (g *Group) PATCH(path string, handler func(ctx Context)) error

func (*Group) POST

func (g *Group) POST(path string, handler func(ctx Context)) error

func (*Group) PUT

func (g *Group) PUT(path string, handler func(ctx Context)) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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