Exemplo n.º 1
0
Arquivo: main.go Projeto: rajjan/qstn
func entriesRandom(c *app.Context) {
	s, entry := api.EntryRand(c)

	if s != 200 {
		c.Error(s)
		return
	}

	c.JSON(entry)
}
Exemplo n.º 2
0
Arquivo: main.go Projeto: rajjan/qstn
func entriesNew(c *app.Context) {
	s, entry := api.EntryPost(c)

	if s != 201 {
		c.Error(s)
		return
	}

	c.JSON(entry)
}
Exemplo n.º 3
0
Arquivo: main.go Projeto: rajjan/qstn
func entriesGet(c *app.Context) {
	id := c.Seg(2)

	s, entry := api.EntryGet(c, id)

	if s != 200 {
		c.Error(s)
		return
	}

	c.JSON(entry)
}
Exemplo n.º 4
0
Arquivo: main.go Projeto: rajjan/qstn
func entriesID(c *app.Context) {
	if c.Seg(2) == "random" {
		entriesRandom(c)
		return
	}

	switch c.R.Method {
	case "GET":
		entriesGet(c)
		return
	}

	c.Error(404)
}
Exemplo n.º 5
0
Arquivo: main.go Projeto: rajjan/qstn
func entries(c *app.Context) {
	segs := c.Segs()
	size := len(segs)

	switch {
	case size > 2:
		c.Error(404)
		return
	case size == 2:
		entriesID(c)
		return
	}

	switch c.R.Method {
	case "POST":
		entriesNew(c)
		return
	}

	c.Error(404)
}
Exemplo n.º 6
0
Arquivo: main.go Projeto: rajjan/qstn
func catch(c *app.Context) {
	c.Error(404)
}