Permalink
Fetching contributors…
Cannot retrieve contributors at this time
29 lines (22 sloc) 589 Bytes
package main
import (
"github.com/ant0ine/go-json-rest/rest"
"log"
"net/http"
)
func main() {
api := rest.NewApi()
api.Use(rest.DefaultDevStack...)
router, err := rest.MakeRouter(
rest.Get("/message", func(w rest.ResponseWriter, req *rest.Request) {
w.WriteJson(map[string]string{"Body": "Hello World!"})
}),
)
if err != nil {
log.Fatal(err)
}
api.SetApp(router)
http.Handle("/api/", http.StripPrefix("/api", api.MakeHandler()))
http.Handle("/static/", http.StripPrefix("/static", http.FileServer(http.Dir("."))))
log.Fatal(http.ListenAndServe(":8080", nil))
}