Implemented forum overview

This commit is contained in:
2016-11-19 02:58:00 +09:00
parent e23f843450
commit b5be7e9cef
17 changed files with 130 additions and 13 deletions

15
api.go
View File

@ -3,7 +3,6 @@ package main
import (
"sort"
"strings"
"time"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
@ -11,7 +10,6 @@ import (
func init() {
app.Get("/all/anime", func(ctx *aero.Context) string {
start := time.Now()
var titles []string
results := make(chan *arn.Anime)
@ -22,7 +20,7 @@ func init() {
}
sort.Strings(titles)
return ctx.Text(s(len(titles)) + " anime fetched in " + s(time.Since(start)) + "\n\n" + strings.Join(titles, "\n"))
return ctx.Text(toString(len(titles)) + "\n\n" + strings.Join(titles, "\n"))
})
app.Get("/api/anime/:id", func(ctx *aero.Context) string {
@ -46,4 +44,15 @@ func init() {
return ctx.JSON(user)
})
app.Get("/api/threads/:id", func(ctx *aero.Context) string {
id := ctx.Get("id")
thread, err := arn.GetThread(id)
if err != nil {
return ctx.Text("Thread not found")
}
return ctx.JSON(thread)
})
}