go: add a method to setup routes
This commit is contained in:
parent
f728a9750f
commit
c945c9fcb7
18
app/routes.go
Normal file
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
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user