path
This commit is contained in:
3
db/db.go
3
db/db.go
@@ -55,7 +55,7 @@ var (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
var err error
|
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 {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -63,6 +63,7 @@ func init() {
|
|||||||
if len(os.Args) > 1{
|
if len(os.Args) > 1{
|
||||||
if os.Args[1] == "install" {
|
if os.Args[1] == "install" {
|
||||||
install()
|
install()
|
||||||
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
9
main.go
9
main.go
@@ -46,7 +46,12 @@ var wsUpgrader = websocket.Upgrader{
|
|||||||
func main() {
|
func main() {
|
||||||
r := gin.Default()
|
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()
|
c.Next()
|
||||||
if len(c.Errors) > 0 {
|
if len(c.Errors) > 0 {
|
||||||
c.JSON(-1, gin.H{
|
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) {
|
api.GET("/timetables", func(c *gin.Context) {
|
||||||
timetables := make([]*db.Timetable, 0)
|
timetables := make([]*db.Timetable, 0)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"name": "web",
|
"name": "web",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
"homepage": "/web",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emotion/react": "^11.10.5",
|
"@emotion/react": "^11.10.5",
|
||||||
"@emotion/styled": "^11.10.5",
|
"@emotion/styled": "^11.10.5",
|
||||||
|
|||||||
Reference in New Issue
Block a user