iris/_examples/mvc/using-method-result/main.go
Gerasimos (Makis) Maropoulos 82b5a1d4ed Enhance the MVC "using-method-result" example. Prev: update to version 8.5.0
Prev Commit: 49ee8f2d75 [formerly 6a3579f2500fc715d7dc606478960946dcade61d]

Changelog: https://github.com/kataras/iris/blob/master/HISTORY.md#mo-09-october-2017--v850

This example is updated with the current commit: https://github.com/kataras/iris/tree/master/_examples/mvc/using-output-result


Former-commit-id: 29486ef014b3667fa1c7c66e11c8e95c76a37e57
2017-10-10 04:46:32 +03:00

44 lines
1.3 KiB
Go

// file: main.go
package main
import (
"github.com/kataras/iris/_examples/mvc/using-method-result/controllers"
"github.com/kataras/iris/_examples/mvc/using-method-result/datasource"
"github.com/kataras/iris/_examples/mvc/using-method-result/middleware"
"github.com/kataras/iris/_examples/mvc/using-method-result/services"
"github.com/kataras/iris"
)
func main() {
app := iris.New()
// Load the template files.
app.RegisterView(iris.HTML("./views", ".html"))
// Register our controllers.
app.Controller("/hello", new(controllers.HelloController))
// Create our movie service (memory), we will bind it to the movies controller.
service := services.NewMovieServiceFromMemory(datasource.Movies)
app.Controller("/movies", new(controllers.MovieController),
// Bind the "service" to the MovieController's Service (interface) field.
service,
// Add the basic authentication(admin:password) middleware
// for the /movies based requests.
middleware.BasicAuth)
// Start the web server at localhost:8080
// http://localhost:8080/hello
// http://localhost:8080/hello/iris
// http://localhost:8080/movies/1
app.Run(
iris.Addr("localhost:8080"),
iris.WithoutVersionChecker,
iris.WithoutServerError(iris.ErrServerClosed),
iris.WithOptimizations, // enables faster json serialization and more
)
}