-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
44 lines (34 loc) · 986 Bytes
/
main.go
File metadata and controls
44 lines (34 loc) · 986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"fmt"
"os"
"path"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"potblog/handlers"
)
func main() {
e := echo.New()
if os.Getenv("ENV") == "dev" {
e.Use(middleware.Logger())
}
e.Use(middleware.GzipWithConfig(middleware.GzipConfig{
Level: 5,
}))
e.Static("/assets", path.Join(os.Getenv("ROOT_DIR"), "assets"))
handlers.Init()
// ---- Home Routes ---- //
e.GET("/", handlers.ServeHomePage)
e.GET("/:language", handlers.ServeHomePage)
e.GET("/languages", handlers.ServeLanguageSelector)
// ---- Article Routes ---- //
e.GET("/:language/article/:article", handlers.ServeArticle)
e.GET("/:language/articles", handlers.ServeArticles)
e.POST("/:language/articles", handlers.ServeSortedArticles)
// ---- Global Routes ---- //
e.GET("/ping", handlers.ServePing)
if os.Getenv("ENV") != "prod" {
e.GET("/ws", handlers.InitHotReloadWebSocket)
}
e.Logger.Fatal(e.Start(fmt.Sprintf(":%s", os.Getenv("PORT"))))
}