-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
61 lines (48 loc) · 1.4 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"flag"
"github.com/AndriyKalashnykov/flight-path/internal/handlers"
"os"
_ "github.com/AndriyKalashnykov/flight-path/docs"
"github.com/AndriyKalashnykov/flight-path/internal/routes"
"github.com/joho/godotenv"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
// @title Flight Path API
// @version 1.0
// @description This is REST API server to determine the flight.go path of a person.
// @termsOfService http://swagger.io/terms/
// @contact.name Andriy Kalashnykov
// @contact.url https://github.com/AndriyKalashnykov/flight-path
// @contact.email [email protected]
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @host localhost:8080
// @BasePath /
// @schemes http
func main() {
// Flags
var envFile string
flag.StringVar(&envFile, "env-file", ".env", "File from which to load environment")
flag.Parse()
// Echo instance
e := echo.New()
e.HideBanner = true
// Load env vars
if err := godotenv.Load(envFile); err != nil {
e.Logger.Fatalf("failed to load environment variables: %v", err)
}
// Middleware
e.Use(middleware.Logger())
e.Use(middleware.Recover())
e.Use(middleware.CORS())
// Handlers
h := handlers.New()
// Routes
routes.SwaggerRoutes(e)
routes.HealthcheckRoutes(e, &h)
routes.FlightRoutes(e, &h)
// Start server
e.Logger.Fatal(e.Start(":" + os.Getenv("SERVER_PORT")))
}