Closed quayilab closed 5 years ago
Hi!
Great question! I have no example for it, but it is rather simple.
Are you using the go-res package for Go? If so, then you can just add the v1 (or v2) as a prefix to the service name:
package main
import res "github.com/jirenius/go-res"
func main() {
s := res.NewService("v1.profile")
s.Handle("model",
res.Access(res.AccessGranted),
res.GetModel(func(r res.ModelRequest) {
r.Model(map[string]string{
"message": "Hello, World!",
})
}),
)
s.ListenAndServe("nats://localhost:4222")
}
And access it with HTTP:
GET /api/v1/profile/model
Though, because dot (.
) is used as separator in resource IDs, you will currently not be able to do /v1.0/
(it would become /v1/0/
). Instead you can do /v1/
or perhaps /v1_0/
.
PS. Currently I am trying to redirect help questions to forum.resgate.io , so if you have more questions, please post them there :). Then I'll use GitHub more for issues and bug reports.
Thank you for fast response. Yes! that's what I need /v1_0/ is enough for me.
Hello, I'm new to Resgate and quite a while with Golang. Is it possible to define api with version? For example:
/api/v1.0/profile
=> will be handled by service "profile_v1", and/api/v2.0/profile
=> will be handled by service "profile_v2"?If it is, may be an example in Golang? Thanks