Refactor: Moving route methods from server.go to app.go

main
Óscar M. Lage 2022-03-18 13:26:13 +01:00
parent 7cc78a118f
commit 5685d2580a
2 changed files with 29 additions and 23 deletions

29
server/app.go Normal file
View File

@ -0,0 +1,29 @@
package server
import (
"fmt"
"github.com/labstack/echo/v4"
"log"
"net/http"
)
func WikiHome(c echo.Context) error {
res := store.GetPage()
fmt.Println(res)
return c.String(http.StatusOK, "WikiHome")
}
func WikiAbout(c echo.Context) error {
id := c.Param("id")
return c.String(http.StatusOK, "About the wiki. id:"+id)
}
func WikiListPages(c echo.Context) error {
fmt.Println("WikiListPages")
res, err := store.GetAllPages()
if err != nil {
log.Panicln(err)
}
fmt.Println(res)
return c.String(http.StatusOK, "WikiListPages")
}

View File

@ -1,11 +1,9 @@
package server
import (
"fmt"
"github.com/labstack/echo/v4"
"github.com/oscarmlage/wikingo/model"
"log"
"net/http"
)
// Depending on config we should open one store or other (Gorm, File,
@ -33,24 +31,3 @@ func Serve() {
// Logger
e.Logger.Fatal(e.Start(":2323"))
}
func WikiHome(c echo.Context) error {
res := store.GetPage()
fmt.Println(res)
return c.String(http.StatusOK, "WikiHome")
}
func WikiAbout(c echo.Context) error {
id := c.Param("id")
return c.String(http.StatusOK, "About the wiki. id:"+id)
}
func WikiListPages(c echo.Context) error {
fmt.Println("WikiListPages")
res, err := store.GetAllPages()
if err != nil {
log.Panicln(err)
}
fmt.Println(res)
return c.String(http.StatusOK, "WikiListPages")
}