go: add a method to setup routes

This commit is contained in:
leo 2023-03-22 23:03:21 +01:00
parent f728a9750f
commit c945c9fcb7
Signed by: wanderer
SSH Key Fingerprint: SHA256:Dp8+iwKHSlrMEHzE3bJnPng70I7LEsa3IJXRH/U+idQ
2 changed files with 19 additions and 4 deletions

18
app/routes.go Normal file

@ -0,0 +1,18 @@
package app
import (
"net/http"
"github.com/labstack/echo/v4"
)
func (a *App) SetupRoutes() {
e := a.E()
e.GET("/", func(c echo.Context) error {
return c.NoContent(http.StatusOK)
})
e.HEAD("/", func(c echo.Context) error {
return c.NoContent(http.StatusOK)
})
}

5
run.go

@ -10,7 +10,6 @@ import (
"git.dotya.ml/mirre-mt/pcmt/app"
"git.dotya.ml/mirre-mt/pcmt/config"
"github.com/labstack/echo/v4"
)
var (
@ -37,9 +36,7 @@ func run() error {
return err
}
e.GET("/", func(c echo.Context) error {
return c.String(http.StatusOK, "Hello there.")
})
a.SetupRoutes()
go func() {
if err = e.Start(*addr); err != nil && err != http.ErrServerClosed {