mirror of
https://github.com/kataras/iris.git
synced 2025-12-18 10:27:06 +00:00
Update to version 8.5.2 | Read HISTORY.md: https://github.com/kataras/iris/blob/master/HISTORY.md#th-12-october-2017--v852
https://github.com/kataras/iris/blob/master/HISTORY.md#th-12-october-2017--v852 Former-commit-id: 2501cf6066812c2aac158d8d6cd4e992a2b538f9
This commit is contained in:
47
_examples/mvc/overview/main.go
Normal file
47
_examples/mvc/overview/main.go
Normal file
@@ -0,0 +1,47 @@
|
||||
// file: main.go
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/kataras/iris/_examples/mvc/overview/datasource"
|
||||
"github.com/kataras/iris/_examples/mvc/overview/repositories"
|
||||
"github.com/kataras/iris/_examples/mvc/overview/services"
|
||||
"github.com/kataras/iris/_examples/mvc/overview/web/controllers"
|
||||
"github.com/kataras/iris/_examples/mvc/overview/web/middleware"
|
||||
|
||||
"github.com/kataras/iris"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := iris.New()
|
||||
|
||||
// Load the template files.
|
||||
app.RegisterView(iris.HTML("./web/views", ".html"))
|
||||
|
||||
// Register our controllers.
|
||||
app.Controller("/hello", new(controllers.HelloController))
|
||||
|
||||
// Create our movie repository with some (memory) data from the datasource.
|
||||
repo := repositories.NewMovieRepository(datasource.Movies)
|
||||
// Create our movie service, we will bind it to the movie controller.
|
||||
movieService := services.NewMovieService(repo)
|
||||
|
||||
app.Controller("/movies", new(controllers.MovieController),
|
||||
// Bind the "movieService" to the MovieController's Service (interface) field.
|
||||
movieService,
|
||||
// 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
|
||||
// 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
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user