1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 18:37:05 +00:00

add a README tutorial on the mvc/overview example

Former-commit-id: c563c4f1ffa98705829e14b189a6976c3a6aa898
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-06-22 17:49:45 +03:00
parent 29d98ac281
commit 9922265454
7 changed files with 469 additions and 8 deletions

View File

@@ -12,10 +12,17 @@ import (
func main() {
app := iris.New()
app.Get("/ping", pong).Describe("healthcheck")
mvc.Configure(app.Party("/greet"), setup)
// http://localhost:8080/greet?name=kataras
app.Listen(":8080", iris.WithLogLevel("debug"))
addr := ":" + environment.Getenv("PORT", ":8080")
app.Listen(addr, iris.WithLogLevel("debug"))
}
func pong(ctx iris.Context) {
ctx.WriteString("pong")
}
/*
@@ -35,9 +42,9 @@ func main() {
| | | |
| | | |
| | | |
+------------+-----+ +-------------------v---v-----------------+ +----+------+
| greeterWithLog | | NewGreetService(Env, DB) GreetService | | greeter |
-------------+-----+ +---------------------------+-------------+ +----+------+
+--------------+-----+ +-------------------v---v-----------------+ +----+------+
| greeterWithLogging | | NewGreetService(Env, DB) GreetService | | greeter |
+--------------+-----+ +---------------------------+-------------+ +----+------+
| | |
| | |
| +-----------------------------------------+ |
@@ -66,8 +73,9 @@ func main() {
func setup(app *mvc.Application) {
// Register Dependencies.
// Tip: A dependency can depend on other dependencies too.
env := environment.ReadEnv("ENVIRONMENT", environment.DEV)
app.Register(
environment.DEV, // DEV, PROD
env, // DEV, PROD
database.NewDB, // sqlite, mysql
service.NewGreetService, // greeterWithLogging, greeter
)