gweb

package
v0.0.0-...-f3abbe6 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

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
const (
	Head     ParamSource = ParamSource("Head")
	UriSlice ParamSource = ParamSource("UriSlice")
	Query    ParamSource = ParamSource("Query")
	Body     ParamSource = ParamSource("Body")
)

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