-
Notifications
You must be signed in to change notification settings - Fork 43
Mvc Controller
YoyoFx edited this page Dec 9, 2020
·
3 revisions
type UserController struct {
mvc.ApiController
userAction models.IUserAction
}
func NewUserController(userAction models.IUserAction) *UserController {
return &UserController{userAction: userAction}
}
func (controller UserController) GetInfo() mvc.ApiResult {
return controller.OK(controller.userAction.Login("zhang"))
}
package main
import (
yoyogo "github.com/yoyofx/yoyogo/web"
......
)
func main() {
configuration := abstractions.NewConfigurationBuilder().
AddEnvironment().
AddYamlFile("config").Build()
yoyogo.NewWebHostBuilder().
UseConfiguration(configuration).
Configure(func(app *yoyogo.WebApplicationBuilder) {
app.UseMvc(func(builder *mvc.ControllerBuilder) {
builder.AddController(contollers.NewUserController)
})
}).Build().Run()
}