Open brentmurphy opened 8 years ago
You mean out of the jsonapi context? You can simply add custom route to your router/muxer.
mux := http.NewServeMux()
mux.HandleFunc("/blub", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))
})
http.ListenAndServe(fmt.Sprintf(":%d", port), mux)
or you can cheat like this: https://github.com/manyminds/api2go/blob/master/examples/crud_example.go#L67
Ok thanks. This is quite a common requirement for the project I'm currently working on (migrating from a Rails codebase). Is there anything in the roadmap for handling this kind of request, or is it just outside the scope of JSONAPI?
this is outside the JSONAPI scope. So like @sharpner said you can add stuff with your own routes as well. You can get the router instance and register your own routes on it as well http://godoc.org/github.com/manyminds/api2go#API.Router
We are currently actually thinking about an easier way to create subroutes for objects because we need this for #244 . But I don't think it will come in the near future because we could not find a clean generic way yet..
Hi,
Does api2go provide a way of handling singular resources? For example, a mapping to the following route: