update so that aicra.New() implements http.Handler

This commit is contained in:
Adrien Marquès 2018-07-11 19:08:09 +02:00
parent 0962196e00
commit e66afdab80
3 changed files with 9 additions and 7 deletions

View File

@ -3,7 +3,7 @@ package main
import ( import (
"git.xdrm.io/example/aicra/db" "git.xdrm.io/example/aicra/db"
e "git.xdrm.io/go/aicra/err" e "git.xdrm.io/go/aicra/err"
i "git.xdrm.io/go/aicra/implement" i "git.xdrm.io/go/aicra/response"
) )
// Redirects to an url from a key // Redirects to an url from a key

View File

@ -5,7 +5,7 @@ import (
"encoding/hex" "encoding/hex"
"git.xdrm.io/example/aicra/db" "git.xdrm.io/example/aicra/db"
e "git.xdrm.io/go/aicra/err" e "git.xdrm.io/go/aicra/err"
i "git.xdrm.io/go/aicra/implement" i "git.xdrm.io/go/aicra/response"
"strconv" "strconv"
"time" "time"
) )

12
main.go
View File

@ -3,20 +3,22 @@ package main
import ( import (
"git.xdrm.io/go/aicra" "git.xdrm.io/go/aicra"
"log" "log"
"net/http"
) )
func main() { func main() {
listen_addr := "127.0.0.1:4242"
server, err := aicra.New("manifest.json") server, err := aicra.New("manifest.json")
if err != nil { if err != nil {
log.Fatal("cannot load config", err) panic("cannot load config")
} }
log.Printf("[Server up] 0.0.0.0:4242\n") log.Printf("[Server up] %s\n", listen_addr)
err = http.ListenAndServe(listen_addr, server)
err = server.Listen(4242)
if err != nil { if err != nil {
log.Fatalf("*** server failed (%s)\n", err) panic(err)
} }
} }