Documentation
¶
Index ¶
- Constants
- func Gopt_AppV2_Main(app AppType, handlers ...iHandler)
- func Gopt_App_Main(app AppType)
- func SubFS(fsys fs.FS, dir string) (ret fs.FS)
- type App
- func (p *App) DELETE(path string, handle func(ctx *Context))
- func (p *App) Delete(path string, handle func(ctx *Context))
- func (p *App) GET(path string, handle func(ctx *Context))
- func (p *App) Get(path string, handle func(ctx *Context))
- func (p *App) HEAD(path string, handle func(ctx *Context))
- func (p *App) Head(path string, handle func(ctx *Context))
- func (p *App) OPTIONS(path string, handle func(ctx *Context))
- func (p *App) Options(path string, handle func(ctx *Context))
- func (p *App) PATCH(path string, handle func(ctx *Context))
- func (p *App) POST(path string, handle func(ctx *Context))
- func (p *App) PUT(path string, handle func(ctx *Context))
- func (p *App) Patch(path string, handle func(ctx *Context))
- func (p *App) Post(path string, handle func(ctx *Context))
- func (p *App) Put(path string, handle func(ctx *Context))
- func (p *App) Route(method, path string, handle func(ctx *Context))
- func (p *App) Static__0(pattern string, dir ...fs.FS)
- func (p *App) Static__1(pattern string, ctx context.Context, url string) (closer fsx.Closer, err error)
- func (p *App) Static__2(pattern string, fs http.FileSystem, allowRedirect ...bool)
- type AppType
- type AppV2
- func (p *AppV2) DELETE(path string, handle func(ctx *Context))
- func (p *AppV2) GET(path string, handle func(ctx *Context))
- func (p *AppV2) HEAD(path string, handle func(ctx *Context))
- func (p *AppV2) OPTIONS(path string, handle func(ctx *Context))
- func (p *AppV2) PATCH(path string, handle func(ctx *Context))
- func (p *AppV2) POST(path string, handle func(ctx *Context))
- func (p *AppV2) PUT(path string, handle func(ctx *Context))
- func (p *AppV2) Route(method, path string, handle func(ctx *Context))
- type Context
- func (p *Context) Accept(mime ...string) string
- func (p *Context) Binary__0(code int, mime string, data []byte)
- func (p *Context) Binary__1(code int, data []byte)
- func (p *Context) Binary__2(data []byte)
- func (p *Context) Binary__3(code int, data string)
- func (p *Context) Binary__4(data string)
- func (p *Context) DATA(code int, mime string, data []byte)
- func (p *Context) Gop_Env(name string) string
- func (p *Context) Html__0(code int, text string)
- func (p *Context) Html__1(text string)
- func (p *Context) Html__2(code int, text []byte)
- func (p *Context) Html__3(text []byte)
- func (p *Context) JSON(code int, data interface{})
- func (p *Context) Json__0(code int, data interface{})
- func (p *Context) Json__1(data interface{})
- func (p *Context) Param(name string) string
- func (p *Context) ParamInt(name string, defval int) int
- func (p *Context) PrettyJSON(code int, data interface{})
- func (p *Context) PrettyJson__0(code int, data interface{})
- func (p *Context) PrettyJson__1(data interface{})
- func (p *Context) Redirect(url string, code ...int)
- func (p *Context) TEXT(code int, mime string, text string)
- func (p *Context) Text__0(code int, mime string, text string)
- func (p *Context) Text__1(code int, text string)
- func (p *Context) Text__2(text string)
- func (p *Context) Text__3(code int, text []byte)
- func (p *Context) Text__4(text []byte)
- func (p *Context) YAP(code int, yapFile string, data interface{})
- func (p *Context) Yap__0(code int, yapFile string, data interface{})
- func (p *Context) Yap__1(yapFile string, data interface{})
- type Engine
- func (p *Engine) DELETE(path string, handle func(ctx *Context))
- func (p *Engine) FS(dir string) (ret fs.FS)
- func (p *Engine) GET(path string, handle func(ctx *Context))
- func (p *Engine) HEAD(path string, handle func(ctx *Context))
- func (p *Engine) Handle(pattern string, f func(ctx *Context))
- func (p *Engine) Handler(mws ...func(h http.Handler) http.Handler) http.Handler
- func (p *Engine) InitYap(fs ...fs.FS)
- func (p *Engine) NewContext(w http.ResponseWriter, r *http.Request) *Context
- func (p *Engine) OPTIONS(path string, handle func(ctx *Context))
- func (p *Engine) PATCH(path string, handle func(ctx *Context))
- func (p *Engine) POST(path string, handle func(ctx *Context))
- func (p *Engine) PUT(path string, handle func(ctx *Context))
- func (p *Engine) Route(method, path string, handle func(ctx *Context))
- func (p *Engine) Run(addr string, mws ...func(h http.Handler) http.Handler) error
- func (p *Engine) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (p *Engine) SetDelims(left, right string)
- func (p *Engine) SetLAS(listenAndServe func(addr string, handler http.Handler) error)
- func (p *Engine) Static(pattern string, dir ...fs.FS)
- func (p *Engine) StaticHttp(pattern string, fsys http.FileSystem, allowRedirect ...bool)
- type H
- type Handler
Constants ¶
const (
GopPackage = true
)
Variables ¶
This section is empty.
Functions ¶
func Gopt_AppV2_Main ¶ added in v0.8.0
func Gopt_AppV2_Main(app AppType, handlers ...iHandler)
Gopt_AppV2_Main is required by Go+ compiler as the entry of a YAP project.
func Gopt_App_Main ¶ added in v0.5.0
func Gopt_App_Main(app AppType)
Gopt_App_Main is required by Go+ compiler as the entry of a YAP project.
Types ¶
type App ¶ added in v0.5.0
type App struct {
Engine
}
App is project class of YAP classfile (old version).
func (*App) DELETE ¶ added in v0.5.0
DELETE is a shortcut for router.Route(http.MethodDelete, path, handle)
func (*App) Delete ¶ added in v0.5.0
Delete is a shortcut for router.Route(http.MethodDelete, path, handle)
func (*App) HEAD ¶ added in v0.5.0
HEAD is a shortcut for router.Route(http.MethodHead, path, handle)
func (*App) Head ¶ added in v0.5.0
Head is a shortcut for router.Route(http.MethodHead, path, handle)
func (*App) OPTIONS ¶ added in v0.5.0
OPTIONS is a shortcut for router.Route(http.MethodOptions, path, handle)
func (*App) Options ¶ added in v0.5.0
Options is a shortcut for router.Route(http.MethodOptions, path, handle)
func (*App) PATCH ¶ added in v0.5.0
PATCH is a shortcut for router.Route(http.MethodPatch, path, handle)
func (*App) POST ¶ added in v0.5.0
POST is a shortcut for router.Route(http.MethodPost, path, handle)
func (*App) Patch ¶ added in v0.5.0
Patch is a shortcut for router.Route(http.MethodPatch, path, handle)
func (*App) Post ¶ added in v0.5.0
Post is a shortcut for router.Route(http.MethodPost, path, handle)
func (*App) Route ¶ added in v0.5.0
Route registers a new request handle with the given path and method.
For GET, POST, PUT, PATCH and DELETE requests the respective shortcut functions can be used.
This function is intended for bulk loading and to allow the usage of less frequently used, non-standardized or custom methods (e.g. for internal communication with a proxy).
func (*App) Static__0 ¶ added in v0.7.1
Static serves static files from a dir (default is "$YapFS/static").
type AppType ¶ added in v0.7.3
type AppType interface { InitYap(fs ...fs.FS) SetLAS(listenAndServe func(addr string, handler http.Handler) error) Route(method, path string, handle func(ctx *Context)) Handle(pattern string, f func(ctx *Context)) Run(addr string, mws ...func(h http.Handler) http.Handler) error }
AppType represents an abstract of YAP applications.
type AppV2 ¶ added in v0.8.0
type AppV2 struct {
App
}
AppV2 is project class of YAP classfile (v2).
func (*AppV2) DELETE ¶ added in v0.8.0
DELETE is a shortcut for router.Route(http.MethodDelete, path, handle)
func (*AppV2) GET ¶ added in v0.8.0
GET is a shortcut for router.Route(http.MethodGet, path, handle)
func (*AppV2) HEAD ¶ added in v0.8.0
HEAD is a shortcut for router.Route(http.MethodHead, path, handle)
func (*AppV2) OPTIONS ¶ added in v0.8.0
OPTIONS is a shortcut for router.Route(http.MethodOptions, path, handle)
func (*AppV2) PATCH ¶ added in v0.8.0
PATCH is a shortcut for router.Route(http.MethodPatch, path, handle)
func (*AppV2) POST ¶ added in v0.8.0
POST is a shortcut for router.Route(http.MethodPost, path, handle)
func (*AppV2) PUT ¶ added in v0.8.0
PUT is a shortcut for router.Route(http.MethodPut, path, handle)
func (*AppV2) Route ¶ added in v0.8.0
Route registers a new request handle with the given path and method.
For GET, POST, PUT, PATCH and DELETE requests the respective shortcut functions can be used.
This function is intended for bulk loading and to allow the usage of less frequently used, non-standardized or custom methods (e.g. for internal communication with a proxy).
type Context ¶
type Context struct { *http.Request http.ResponseWriter // contains filtered or unexported fields }
func (*Context) Accept ¶
Accept header specifies: Accept: <MIME_type>/<MIME_subtype> Accept: <MIME_type>/* Accept: */* Multiple types, weighted with the quality value syntax: Accept: text/html, application/xhtml+xml, application/xml;q=0.9, image/webp, */*;q=0.8 FIXME: 1. quality value not supported, 2. don't need parse all, just find the first match with a spliter iterator
func (*Context) Gop_Env ¶ added in v0.8.0
Gop_Env returns the value associated with the name. If the name exists in URL query, it returns the first value for the name.
func (*Context) Param ¶ added in v0.2.0
Param returns the value associated with the name. If the name exists in URL query, it returns the first value for the name.
func (*Context) PrettyJSON ¶
func (*Context) PrettyJson__0 ¶ added in v0.5.0
func (*Context) PrettyJson__1 ¶ added in v0.5.0
func (p *Context) PrettyJson__1(data interface{})
func (*Context) Redirect ¶ added in v0.7.0
Redirect replies to the request with a redirect to url, which may be a path relative to the request path.
type Engine ¶
func (*Engine) DELETE ¶ added in v0.2.0
DELETE is a shortcut for router.Route(http.MethodDelete, path, handle)
func (*Engine) GET ¶ added in v0.2.0
GET is a shortcut for router.Route(http.MethodGet, path, handle)
func (*Engine) HEAD ¶ added in v0.2.0
HEAD is a shortcut for router.Route(http.MethodHead, path, handle)
func (*Engine) Handler ¶ added in v0.7.3
Handler returns the main entry that responds to HTTP requests.
func (*Engine) NewContext ¶
func (*Engine) OPTIONS ¶ added in v0.2.0
OPTIONS is a shortcut for router.Route(http.MethodOptions, path, handle)
func (*Engine) PATCH ¶ added in v0.2.0
PATCH is a shortcut for router.Route(http.MethodPatch, path, handle)
func (*Engine) POST ¶ added in v0.2.0
POST is a shortcut for router.Route(http.MethodPost, path, handle)
func (*Engine) PUT ¶ added in v0.2.0
PUT is a shortcut for router.Route(http.MethodPut, path, handle)
func (*Engine) Route ¶ added in v0.2.0
Route registers a new request handle with the given path and method.
For GET, POST, PUT, PATCH and DELETE requests the respective shortcut functions can be used.
This function is intended for bulk loading and to allow the usage of less frequently used, non-standardized or custom methods (e.g. for internal communication with a proxy).
func (*Engine) Run ¶
Run listens on the TCP network address addr and then calls Serve with handler to handle requests on incoming connections. Accepted connections are configured to enable TCP keep-alives.
func (*Engine) ServeHTTP ¶ added in v0.2.0
func (p *Engine) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP makes the router implement the http.Handler interface.
func (*Engine) SetDelims ¶ added in v0.8.1
SetDelims sets the action delimiters to the specified strings. Nested template definitions will inherit the settings. An empty delimiter stands for the corresponding default: {{ or }}.
func (*Engine) SetLAS ¶ added in v0.7.3
SetLAS sets listenAndServe func to listens on the TCP network address addr and to handle requests on incoming connections.
func (*Engine) Static ¶ added in v0.7.0
Static serves static files from a dir (default is "$YapFS/static").
func (*Engine) StaticHttp ¶ added in v0.7.1
func (p *Engine) StaticHttp(pattern string, fsys http.FileSystem, allowRedirect ...bool)
StaticHttp serves static files from fsys (http.FileSystem).