gweb

package
v0.0.0-...-2bcc11b Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	Head     = ParamSource("Head")
	UriSlice = ParamSource("UriSlice")
	Query    = ParamSource("Query")
	Body     = ParamSource("Body")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Ctx

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

func (Ctx) Body2File

func (c Ctx) Body2File(key string) ([]byte, error)

receive file from HTTP body

func (Ctx) Body2JSON

func (c Ctx) Body2JSON(output interface{}) error

Unmarshal HTTP body to json

func (Ctx) GetParam

func (c Ctx) GetParam(src ParamSource, key string, idx int) Param

TODO

func (Ctx) GetQueryParamInt

func (c Ctx) GetQueryParamInt(key string) (int, error)

http://example.com/path1/path2?k1=v1&k2=v2 [k1,v1] and [k2, v2] are query params

func (Ctx) GetQueryParamString

func (c Ctx) GetQueryParamString(key string) string

http://example.com/path1/path2?k1=v1&k2=v2 [k1,v1] and [k2, v2] are query params

func (Ctx) GetRUriSliceInt

func (c Ctx) GetRUriSliceInt(name string) (int, error)

http://example.com/path1/path2?k1=v1&k2=v2 path1 and path2 are router slices

func (Ctx) GetUriSliceString

func (c Ctx) GetUriSliceString(name string) string

http://example.com/path1/path2?k1=v1&k2=v2 path1 and path2 are router slices

func (Ctx) PrintHead

func (c Ctx) PrintHead()

func (Ctx) ServeBufferFile

func (c Ctx) ServeBufferFile(filename string, r io.ReadSeeker)

func (Ctx) ServeDiskFile

func (c Ctx) ServeDiskFile(filename, filepath string)

func (Ctx) WriteError

func (c Ctx) WriteError(code int, err error, errFmt ErrFormatter)

func (Ctx) WriteMapJSON

func (c Ctx) WriteMapJSON(code int, values map[string]interface{})

func (Ctx) WriteString

func (c Ctx) WriteString(code int, format string, values ...interface{})

func (Ctx) WriteStructJSON

func (c Ctx) WriteStructJSON(code int, output interface{}, errFmt ErrFormatter)

type ErrFormatter

type ErrFormatter func(err error) string

type HandlerFunc

type HandlerFunc func(*Ctx)

type Param

type Param struct {
	Value *string
}

func (Param) I64

func (p Param) I64() (int64, bool)

func (Param) MustI64

func (p Param) MustI64(defValIfNotExist int64) int64

func (Param) MustString

func (p Param) MustString(defValIfNotExist string) string

func (Param) String

func (p Param) String() (string, bool)

type ParamSource

type ParamSource string

type Router

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

func NewRouter

func NewRouter() *Router

func (*Router) Handle

func (r *Router) Handle(m ghttp.Method, relativePath string, fn HandlerFunc)

func (*Router) Serve

func (r *Router) Serve(addr string) error

func (*Router) Static

func (r *Router) Static(relativePath, root string)

func (*Router) StaticFile

func (r *Router) StaticFile(relativePath, filepath string)

Jump to

Keyboard shortcuts

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