Kong / unirest-java

Unirest in Java: Simplified, lightweight HTTP client library.
http://kong.github.io/unirest-java/
MIT License
2.6k stars 592 forks source link

Add supporting baseUrl part in request #342

Closed dilook closed 4 years ago

dilook commented 4 years ago

Is your feature request related to a problem? Please describe. I'd like to be able to set base part of url for easy testing with unirest

Describe the solution you'd like Add config to set base url part, smth like that:


@BeforeMethod
void setUp() {
    Unirest.config().setDefaultBaseUrl("http://localhost/api/v1")
}

@Test
void testForMethod1() {
    Unirest.get("method1").asString()
...
}

void testForMethod2() {
    Unirest.get("method2").asString()
...
}

Describe alternatives you've considered Now I'm everytime write full path in each test:

@Test
void testForMethod1() {
    Unirest.get("http://localhost/api/v1/method1").asString()
...
}

void testForMethod2() {
    Unirest.get("http://localhost/api/v1/method2").asString()
...
}
ryber commented 4 years ago

this is complete in 4.7.00 https://github.com/Kong/unirest-java/blob/master/unirest/src/test/java/BehaviorTests/BaseUrlTest.java

dilook commented 4 years ago

Cool, thanks