This commit is contained in:
Alex Myasoedov 2016-02-29 21:29:47 +02:00
parent 50a780483f
commit e341b3fd8d
2 changed files with 17 additions and 9 deletions

View file

@ -2,12 +2,14 @@ package main
import (
. "github.com/franela/goblin"
"github.com/gin-gonic/gin"
"net/http"
"net/http/httptest"
"testing"
)
func performRequest(method, path string) *httptest.ResponseRecorder {
gin.SetMode("test")
app := NewApp()
req, _ := http.NewRequest(method, path, nil)
w := httptest.NewRecorder()

14
main.go
View file

@ -11,6 +11,14 @@ func NewApp() *gin.Engine {
r := gin.Default()
r.LoadHTMLGlob("templates/*.tmpl")
r.GET("/", func(c *gin.Context) {
c.HTML(200, "index.tmpl", gin.H{
"pubTo": "Users",
})
})
r.GET("/slides.md", func(c *gin.Context) {
body, err := ioutil.ReadFile("initial-slides.md")
if err != nil {
@ -19,10 +27,8 @@ func NewApp() *gin.Engine {
c.String(200, string(body))
})
r.GET("/", func(c *gin.Context) {
c.HTML(200, "index.tmpl", gin.H{
"pubTo": "Users",
})
r.PUT("/slides.md", func(c *gin.Context) {
c.String(403, "")
})
// Get user value