-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
47 lines (37 loc) · 993 Bytes
/
main.go
File metadata and controls
47 lines (37 loc) · 993 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
45
46
47
package main
import (
"fmt"
"net/http"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/rs/zerolog/log"
"github.com/pmdroid/jira-youtrack-proxy/internal/config"
"github.com/pmdroid/jira-youtrack-proxy/internal/handler"
)
func main() {
cfg, err := config.LoadConfig()
if err != nil {
log.
Fatal().
Err(err).
Msg("Failed to build config")
panic(1)
}
e := echo.New()
e.HideBanner = true
e.HidePort = true
e.Use(middleware.Logger())
e.Use(middleware.Recover())
e.POST("/rest/api/2/issue", func(c echo.Context) error {
return handler.HandleCreateIssue(c, cfg)
})
e.GET("/rest/api/2/project/:id", func(c echo.Context) error {
return handler.HandleProjectDetails(c, cfg)
})
e.GET("/health", func(c echo.Context) error {
return c.String(http.StatusOK, "OK")
})
fmt.Printf("Starting proxy server on port %s\n", cfg.Port)
fmt.Printf("YouTrack URL: %s\n", cfg.YouTrackURL)
e.Logger.Fatal(e.Start(":" + cfg.Port))
}