Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

Inject URL into Rest Service #171

Description

@Marco9000

When using a REST service from another project (shared rest implementation) it would be good to be able to set the URL for the service where it is used.

The choice the developer has today is to send the URL as a parameter like the example below which works fine but I would prefer to do it once.
@get("{url}/{domain}/entity")
@accept(MediaType.APPLICATION_JSON)
ResponseEntity getEntity(String url, String domain);

These are two examples on how I would like to do it:

  1. Declaring URL when declaring service
    @restservice(@stringres(R.string.myurl))
    RestService myRestService
  2. adding it to service after it has been initialized
    myRestService.setBaseUrl(theServiceUrl);

Activity

  1. pyricau commented on May 24, 2012

    @pyricau
    Contributor

    I also updated the corresponding wiki page:

    If you need different ROOT_URL values, you can add a void setRootUrl(String rootUrl) method to the interface.

    @Rest
    public interface MyRestClient {
        @Get("/events")
        EventList getEvents();
        void setRootUrl(String rootUrl);
    }

    This can be useful if you need to create builds for different environments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions