path
This commit is contained in:
3
db/db.go
3
db/db.go
@@ -55,7 +55,7 @@ var (
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
DB, err = sql.Open("postgres", "postgres://itsc@localhost:5432/itsc?sslmode=disable")
|
||||
DB, err = sql.Open("postgres", os.Getenv("POSTGRES_CONNSTR"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@@ -63,6 +63,7 @@ func init() {
|
||||
if len(os.Args) > 1{
|
||||
if os.Args[1] == "install" {
|
||||
install()
|
||||
os.Exit(0)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
9
main.go
9
main.go
@@ -46,7 +46,12 @@ var wsUpgrader = websocket.Upgrader{
|
||||
func main() {
|
||||
r := gin.Default()
|
||||
|
||||
r.Use(func(c *gin.Context) {
|
||||
group := r.Group("/")
|
||||
|
||||
group.StaticFile("/", "./web/build/index.html")
|
||||
group.Static("/web", "./web/build")
|
||||
|
||||
group.Use(func(c *gin.Context) {
|
||||
c.Next()
|
||||
if len(c.Errors) > 0 {
|
||||
c.JSON(-1, gin.H{
|
||||
@@ -56,7 +61,7 @@ func main() {
|
||||
}
|
||||
})
|
||||
|
||||
api := r.Group("/api")
|
||||
api := group.Group("/api")
|
||||
|
||||
api.GET("/timetables", func(c *gin.Context) {
|
||||
timetables := make([]*db.Timetable, 0)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"name": "web",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"homepage": "/web",
|
||||
"dependencies": {
|
||||
"@emotion/react": "^11.10.5",
|
||||
"@emotion/styled": "^11.10.5",
|
||||
|
||||
Reference in New Issue
Block a user