-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
38 lines (33 loc) · 834 Bytes
/
main.go
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
package main
import (
"fmt"
"log"
"github.com/CapregSoft/EasyFileShare/api/config"
"github.com/CapregSoft/EasyFileShare/api/handler"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
)
func main() {
config, err := config.FromFile("./env.json")
if err != nil {
log.Fatal(err)
}
e := echo.New()
e.Use(middleware.Logger())
e.Use(middleware.RequestID())
api := e.Group("/api/v1", serverHeader)
api.GET("/ping", handler.Ping)
api.POST("/encode/", handler.Ping)
api.GET("/{link}", handler.Ping)
api.GET("/{link}/stats", handler.Ping)
err = e.Start(fmt.Sprintf(":%v", config.Server.Port))
if err != nil {
log.Fatal(err)
}
}
func serverHeader(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
c.Response().Header().Set("x-version", "Test/v1.0")
return next(c)
}
}