Documentation ¶
Overview ¶
beego's Wrapper
Example ¶
err := tingyun.AppInit("tingyun.json") if err != nil { fmt.Println(err) } defer tingyun.AppStop() //"beego.Run" 替换为:=> "tingyun_beego.Run" tingyun_beego.Run()
Output:
Index ¶
- func FindAction(ctx *context.Context) *tingyun.Action
- func GetAction(rw http.ResponseWriter) *tingyun.Action
- func Handler(rootpath string, h http.Handler, options ...interface{}) *beego.App
- func NSHandler(rootpath string, h http.Handler) beego.LinkNamespace
- func NamespaceHandler(n *beego.Namespace, rootpath string, h http.Handler) *beego.Namespace
- func RoutineLocalGetAction() *tingyun.Action
- func RoutineLocalInit(rls Storage)
- func Run(params ...string)
- type Controller
- type Storage
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindAction ¶
API: 在应用过程中 对于没有使用beego.Handler, beego.NSHandler 函数和 beego.Namespace.Handler方法 的方式 使用FindAction获取对应的tingyun.Action
func GetAction ¶
func GetAction(rw http.ResponseWriter) *tingyun.Action
API: 对于使用beego.Handler, beego.NSHandler函数 或 beego.Namespace.Handler方法的方式 使用GetAction获取对应的tingyun.Action 在没有hook的情况下,返回nil
func Handler ¶
替换beego.Handler
Example ¶
err := tingyun.AppInit("tingyun.json") if err != nil { fmt.Println(err) } defer tingyun.AppStop() //"beego.Handler" 替换为:=> "tingyun_beego.Handler" tingyun_beego.Handler("/api", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path)) })) //"beego.Run" 替换为:=> "tingyun_beego.Run" tingyun_beego.Run()
Output:
func NSHandler ¶
func NSHandler(rootpath string, h http.Handler) beego.LinkNamespace
替换beego.NSHandler
Example ¶
err := tingyun.AppInit("tingyun.json") if err != nil { fmt.Println(err) } defer tingyun.AppStop() ns := beego.NewNamespace("/v1", beego.NSCond(func(ctx *context.Context) bool { if ctx.Input.Domain() == "127.0.0.1" { return true } return false }), //"beego.NSHandler" 替换为:=> "tingyun_beego.NSHandler" tingyun_beego.NSHandler("/handler", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path)) })), ) beego.AddNamespace(ns) //"beego.Run" 替换为:=> "tingyun_beego.Run" tingyun_beego.Run()
Output:
func NamespaceHandler ¶
替换beego.Namesapce.Handler
Example ¶
err := tingyun.AppInit("tingyun.json") if err != nil { fmt.Println(err) } defer tingyun.AppStop() ns := beego.NewNamespace("/v1", beego.NSCond(func(ctx *context.Context) bool { if ctx.Input.Domain() == "127.0.0.1" { return true } return false }), ) //"beego.Namespace.Handler" 替换为:=> "tingyun_beego.NamespaceHandler" //ns.Handler("/ttt", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { tingyun_beego.NamespaceHandler(ns, "/ttt", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "ttt Hello, %q", html.EscapeString(r.URL.Path)) })) beego.AddNamespace(ns) //"beego.Run" 替换为:=> "tingyun_beego.Run" tingyun_beego.Run()
Output:
func RoutineLocalGetAction ¶
func RoutineLocalGetAction() *tingyun.Action
func RoutineLocalInit ¶
func RoutineLocalInit(rls Storage)
Types ¶
type Controller ¶
type Controller struct {
beego.Controller
}
要使用tingyun_beego.Controller 替换 beego.Controller
Example ¶
err := tingyun.AppInit("tingyun.json") if err != nil { fmt.Println(err) } defer tingyun.AppStop() //"beego.Controller" 替换为:=> "tingyun_beego.Controller" //type MainController struct { // tingyun_beego.Controller //} //func (this *MainController) Get() { // this.Ctx.WriteString("hello world") //} beego.Router("/", &MainController{}) //"beego.Run" 替换为:=> "tingyun_beego.Run" tingyun_beego.Run()
Output:
func (*Controller) Finish ¶
func (c *Controller) Finish()
Source Files ¶
Click to show internal directories.
Click to hide internal directories.