main.go 738 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package main
  2. import (
  3. "LMS/controller"
  4. "LMS/database"
  5. "LMS/environment"
  6. "LMS/service"
  7. "github.com/kataras/iris/v12"
  8. "github.com/kataras/iris/v12/mvc"
  9. )
  10. func main() {
  11. app := iris.New()
  12. app.Get("/ping", pong).Describe("healthcheck")
  13. mvc.Configure(app.Party("/greet"), setup)
  14. // http://localhost:8080/greet?name=kataras
  15. app.Listen(":8181", iris.WithLogLevel("debug"))
  16. }
  17. func pong(ctx iris.Context) {
  18. ctx.WriteString("pong")
  19. }
  20. func setup(app *mvc.Application) {
  21. // Register Dependencies.
  22. app.Register(
  23. environment.DEV, // DEV, PROD
  24. database.NewDB, // sqlite, mysql
  25. service.NewGreetService, // greeterWithLogging, greeter
  26. )
  27. // Register Controllers.
  28. app.Handle(new(controller.GreetController))
  29. }