Go rewrite

This commit is contained in:
2016-10-21 19:31:42 +09:00
commit 8d4cc6439a
5 changed files with 99 additions and 0 deletions

29
src/main.go Normal file
View File

@ -0,0 +1,29 @@
package main
import (
"fmt"
"time"
web "github.com/kataras/iris"
)
func main() {
InitDatabase()
web.Get("/", func(ctx *web.Context) {
ctx.Response.Header.Set("Content-Type", "text/html;charset=utf-8")
ctx.Write(ctx.Request.URI().String())
})
web.Get("/anime/:id", func(ctx *web.Context) {
start := time.Now()
id, _ := ctx.ParamInt("id")
anime := GetAnime(id)
ctx.Write(anime.Title.Romaji + "\n")
ctx.Write(anime.Description)
fmt.Println(time.Since(start))
})
web.Listen(":8082")
}