2020-04-05 20:06:15 +00:00
|
|
|
package web
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path"
|
|
|
|
|
|
|
|
"git.1750studios.com/ToddShepard/DB640/internal/config"
|
2020-04-10 16:16:16 +00:00
|
|
|
"github.com/gin-contrib/cors"
|
2020-04-05 20:06:15 +00:00
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Init intizializes the web server
|
|
|
|
func Init() {
|
|
|
|
r := gin.Default()
|
2020-04-10 16:16:16 +00:00
|
|
|
r.Use(cors.Default())
|
2020-04-05 20:06:15 +00:00
|
|
|
|
2020-04-11 03:29:03 +00:00
|
|
|
r.StaticFile("/", path.Join(config.C.Web.WebDir, "index.html"))
|
2020-04-05 20:06:15 +00:00
|
|
|
r.Static("/static", path.Join(config.C.Web.WebDir, "static"))
|
|
|
|
|
|
|
|
r.GET("/betriebsstellen/", getBetriebsstellen)
|
|
|
|
r.GET("/betriebsstellen/:code", getBetriebsstelleByCode)
|
|
|
|
|
|
|
|
if config.C.Web.BindUnix {
|
2020-04-11 03:16:48 +00:00
|
|
|
go r.RunUnix(config.C.Web.Bind)
|
2020-04-05 20:06:15 +00:00
|
|
|
} else {
|
2020-04-11 03:16:48 +00:00
|
|
|
go r.Run(config.C.Web.Bind)
|
2020-04-05 20:06:15 +00:00
|
|
|
}
|
|
|
|
}
|