-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.go
37 lines (29 loc) · 806 Bytes
/
server.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
package main
import (
"fmt"
"github.com/Guilospanck/stripe-go-integration/handlers"
"github.com/joho/godotenv"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
func main() {
err := godotenv.Load(".env")
if err != nil {
fmt.Println("Could not load environment variables")
return
}
// Echo instance
e := echo.New()
// Gets the IP from caller when not using proxy
e.IPExtractor = echo.ExtractIPDirect()
// Gets the IP from caller when using X-Forwarded-For in the proxy (nginx, for example)
// e.IPExtractor = echo.ExtractIPFromXFFHeader()
// Middleware
e.Use(middleware.Logger())
e.Use(middleware.Recover())
// Routes
e.GET("/ping", handlers.PingHandler)
e.POST("/webhook", handlers.WebhookHandler)
// Start server
e.Logger.Fatal(e.Start(":4444"))
}