dongwu1410 2015-10-20 11:39
浏览 72
已采纳

我可以直接在没有beego中的路由器的情况下直接从主站调用控制器吗

I have a controller say XXController from package xx. Now i want this controller to be called as an function like xx.XXController{}. And the login inside controller should get executed.

  • 写回答

1条回答 默认 最新

  • duan0414 2016-06-27 13:51
    关注

    This is an example I found using Beego Framework. Hope this helps.

    Link to example Code

    package routers
    
    import (
        "github.com/astaxie/beego"
        ctl "github.com/ikeikeikeike/beego-samples/auth/controllers"
    )
    
    func init() {
        beego.Router("/", &ctl.UsersController{}, "get:Index")
        beego.Router("/login", &ctl.LoginController{}, "get,post:Login")
        beego.Router("/logout", &ctl.LoginController{}, "get:Logout")
        beego.Router("/signup", &ctl.LoginController{}, "get,post:Signup")
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?