-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
37 lines (31 loc) · 954 Bytes
/
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
package main
import (
"net/http"
"os"
"path/filepath"
"github.com/gin-gonic/gin"
)
func main() {
//os.Setenv("GIN_MODE", "release")
//gin.SetMode(gin.ReleaseMode)
// Creates a gin router with default middleware:
// logger and recovery (crash-free) middleware
router := gin.Default()
router.StaticFS("/templates", http.Dir(filepath.Join(os.Getenv("GOPATH"),
"src/github.com/ameykpatil/gospike/templates")))
router.LoadHTMLGlob(filepath.Join(os.Getenv("GOPATH"),
"src/github.com/ameykpatil/gospike/templates/*"))
router.GET("/", func(c *gin.Context) {
c.HTML(http.StatusOK, "index.tmpl", gin.H{
"title": "GoSpike",
})
})
router.GET("/connect", Connect)
router.GET("/record/:key", GetRecord)
router.POST("/record", AddRecord)
//router.PUT("/record/:key", updateRecord)
router.DELETE("/record/:key", DeleteRecord)
// By default it serves on :8080 unless a
// PORT environment variable was defined.
router.Run(":4848")
}