-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.go
53 lines (41 loc) · 1.24 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"brok/navnetjener/api"
"brok/navnetjener/utils"
"os"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
)
func main() {
router := utils.Setup()
apiRoutes(router)
serveApplication(router)
}
func apiRoutes(router *gin.Engine) {
// Group API endpoints in /v1
v1 := router.Group("/v1")
limit, exists := os.LookupEnv("LIMIT_ENDPOINTS")
if !exists {
logrus.Warn("LIMIT_ENDPOINTS environment variable not set, using default false")
limit = "false"
}
// Don't use privileged endpoints if feature toggle LIMIT_ENDPOINTS is set
if limit == "false" {
v1.POST("/wallet", api.CreateWallet)
v1.GET("/wallet/:walletAddress", api.GetWalletByWalletAddress)
v1.GET("/aksjeeier/:id", api.GetAllForetakForAksjeeier)
v1.GET("/aksjebok/:orgnr/balanse/:id", api.GetNumberOfSharesForOwnerOfAForetak)
v1.POST("/aksjebok/:orgnr/aksjeeier", api.GetOwnersForForetak)
}
v1.GET("/aksjebok/", api.GetForetak)
v1.GET("/aksjebok/:orgnr", api.GetForetakByOrgnr)
v1.GET("/health/", api.Health)
}
func serveApplication(router *gin.Engine) {
port, exists := os.LookupEnv("SERVER_PORT")
if !exists {
logrus.Warn("SERVER_PORT environment variable not set, using default port 8080 ")
port = "8080"
}
router.Run(":" + port)
}