-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
38 lines (28 loc) · 733 Bytes
/
main.go
File metadata and controls
38 lines (28 loc) · 733 Bytes
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
package main
import (
"fmt"
"io"
// "net/http"
"github.com/gin-gonic/gin"
)
func main() {
router := gin.Default()
router.Static("/assets", "./web/pub/assets/")
router.StaticFile("/", "./web/pub/index.html")
router.NoRoute(func(c *gin.Context) {
c.Redirect(307, "/")
})
// no login page exists yet
router.StaticFile("/login", "./web/pub/login.html")
// TODO: Check DB, Create Cookie, Send Cookie
router.POST("login", func(c *gin.Context) {
fmt.Println(io.ReadAll(c.Request.Body))
c.JSON(200, gin.H{"yummy": "horse"})
})
// does not exists yet
router.GET("/dashboard", func(c *gin.Context) {
c.Redirect(307, "/")
})
fmt.Println("\nView the site at:\nhttp://localhost:8080\n")
router.Run(":8080")
}