delphi.market/server/server.go
ekzyis 7558655458 refactor: Structure code into different packages
I have put too much code into the same files.

Also, I put everything into the same package: main.

This package is only meant for executables.

Therefore, I have refactored my code to use multiple packages. These packages also guarantee separation of concerns since Golang doesn't allow cyclic imports.
2023-09-10 23:13:08 +02:00

32 lines
556 B
Go

package server
import (
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"git.ekzyis.com/ekzyis/delphi.market/server/router"
)
type Server struct {
*echo.Echo
}
func NewServer() *Server {
e := echo.New()
e.Static("/", "public")
e.Renderer = router.T
router.AddRoutes(e)
e.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
Format: "${time_custom} ${method} ${uri} ${status}\n",
CustomTimeFormat: "2006-01-02 15:04:05.00000-0700",
}))
e.HTTPErrorHandler = httpErrorHandler
return &Server{e}
}