Hopen- Golang web极速开发框架

网友投稿 505 2022-10-20

Hopen- Golang web极速开发框架

Hopen- Golang web极速开发框架

Golang web极速开发框架。

使用:

main

func init(){ //hopen.AddRouter("/test/:id([0-9]+)/sss",&testController.TestController{},"get:tohtml"); //hopen.AddAutoRouter("/test/:id([0-9]+)/tohtml",&testController.TestController{}); hopen.AddPrefixAutoRouter("/test",&testController.TestController{});} func main(){  hopen.Run()}

controller

type TestController struct {    hopen.Controller } func (t *TestController) Sayhello() { print(t.R.Form.Get("id"))} func (t *TestController) Tojson() { m := make(map[string]string)    m["show_branch"] = "false" m["t0"] = "true" m["t1"] = "true" t.SetValue("data", m)    t.SetValue("msg", "测试")    t.SetValue("status", "测试")    t.RenderJson()} type Servers struct { XMLName xml.Name `xml:"server"` ServerName string `xml:"serverName"` ServerIP string `xml:"serverIP"` } func (t *TestController) ToXml() { v := &Servers{ServerName:"2",ServerIP:"3"}    t.RenderXml(v)} func (t *TestController) ToHtml() {    id ,_ := t.GetI("id",-1);    t.SetValue("msg", "id is " + strconv.FormatInt(int64(id), 10))    t.Render("tmpl/welcome.html")} func (t *TestController) RedirectTo() {      t.Redirect("tojson")}

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:[leetcode] 1422. Maximum Score After Splitting a String
下一篇:[leetcode] 859. Buddy Strings
相关文章

 发表评论

暂时没有评论,来抢沙发吧~