GoREST端点路径

I'm writting a web service with Go and I'd like to have url like :

http://example.com/WEB/service.wfs?param1=2&param2=test.....

I'm using GoREST and my Endpoint url is :

method:"GET" path:"/WEB/service.wfs?{param:string}" output:"string"

My problem is that it never return the "param" but it does if I use the endpoint :

method:"GET" path:"/WEB/service.wfs/{param:string}" output:"string"

Is there a way to handle the "?" ?

I have had a look at the GoREST package you are using and can not see any way of doing this.

I have always used gorillatoolkit pat package.

gorillatoolkit

There is an example of what you want to do about half way down.

category := req.URL.Query().Get(":category")

This way you can get the query parameters on the request URL by the key.

Hope this helps.

You can do this in gorest though it's not as nice as gorest's preferred mechanism.

Don't include your query parameters in your endpoint definition

method:"GET" path:"/WEB/service.wfs" output:"string"

Instead, you can get at the context from your registered end point and get the query parameters using something like

func (serv MyService) HelloWorld() (result string) {
    r := serv.Context.Request()
    u, _ := url.Parse(r.URL.String())
    q := u.Query()
    result = "Buono estente " + q["hi"][0]
    return
}