Skip to content

Instantly share code, notes, and snippets.

View matey-jack's full-sized avatar

Robert Jack Will matey-jack

View GitHub Profile
@matey-jack
matey-jack / RestTemplateExtensions.kt
Last active November 14, 2019 10:19
Automatically append query string parameters during a call to Spring's RestTemplate
import org.springframework.http.ResponseEntity
import org.springframework.web.client.RestTemplate
/**
* This method behaves like 'getForEntity', but automatically extends the uriTemplate
* with the queryString part, adding only query parameters for which the value is not null.
* Map keys of the 'queryParams' will be used as keys in the queryString.
*
* See unit tests for excellent usage examples.
*