-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
55 lines (43 loc) · 1.3 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
package main
import (
"fmt"
log "github.com/apex/log"
"github.com/gabeduke/level/docs"
"github.com/gabeduke/level/pkg/router"
"github.com/gabeduke/level/pkg/util"
swaggerFiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger"
)
// @title Level API
// @version 1.0
// @description API to get the water level from NWS
// @termsOfService http://swagger.io/terms/
// @contact.name Dukemon
// @contact.url leetserve.com
// @contact.email gabeduke@gmail.com
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
var version = "dev"
func main() {
port := util.GetPort()
docs.SwaggerInfo.Version = version
docs.SwaggerInfo.Host = fmt.Sprintf("localhost:%s", port)
docs.SwaggerInfo.BasePath = "/api/v1"
docs.SwaggerInfo.Schemes = []string{"http", "https"}
// get router
r := router.GetRouter()
// swagger
u := fmt.Sprintf("http://localhost:%s/swagger/doc.json", port)
url := ginSwagger.URL(u) // The url pointing to API definition
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, url))
// run
log.WithField("Port", port).Info("Starting service..")
log.Debug("Browse API: http://localhost:8081/swagger/index.html")
err := r.Run(fmt.Sprintf(":%s", port))
if err != nil {
log.Fatal(err.Error())
}
}
func init() {
util.InitLogger()
}