Jochen Kemnade created GROOVY-12583:
---------------------------------------

             Summary: Improve support for base URLs with context path
                 Key: GROOVY-12583
                 URL: https://issues.apache.org/jira/browse/GROOVY-12583
             Project: Groovy
          Issue Type: Improvement
          Components: groovy-http-builder
    Affects Versions: 6.0.0
            Reporter: Jochen Kemnade


If you have an endpoint with a context path, e.g 
{{https://server.example/api}}, it will not be included in the request path.

{code:groovy}
@HttpBuilderClient('https://server.example/api')
interface Api {

  @Get('/users')
  List getUsers()

  @Get('/api/users')
  List getUsers2()
}

def api = Api.create{
  baseUri 'https://server.example/api'
}
{code}

{{api.getUsers()}} will not work, only {{api.getUsers2()}} will. But if you 
want to use the same API interface for multiple endpoints (e.g. 
{{'https://server.example/api'}} and {{'https://otherserver.example/apiv1'}}), 
including the context path in the path template is not desirable.

What does work is  

{code:groovy}
@HttpBuilderClient('https://server.example/api/')
interface Api {

  @Get('users')
  List getUsers3()
}

def api = Api.create{
  baseUri 'https://server.example/api/'
}
{code}
But IMHO, the trailing slash in the baseURi should be optional as well as the 
leading slash in the path template.




--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to