Skip to content

Instantly share code, notes, and snippets.

@Hc747
Created January 14, 2021 02:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hc747/1b686927fe99b833b1d94df6d266e34c to your computer and use it in GitHub Desktop.
Save Hc747/1b686927fe99b833b1d94df6d266e34c to your computer and use it in GitHub Desktop.
Flowable<Boolean> validate(String token) {
final Map<String, String> parameters = [secret: key(SECRET), response: token]
final HttpRequest<Map<String, String>> request = HttpRequest.POST(SITE_VERIFY_ENDPOINT, parameters).contentType(MediaType.APPLICATION_FORM_URLENCODED)
final Flowable<HttpResponse<Map<String, ?>>> exchange = http.exchange(request, Map.class) as Flowable<HttpResponse<Map<String, ?>>>
return exchange.map(response -> {
final Map<String, ?> body = response.body()
if (body == null) {
return false
}
return body.getOrDefault(KEY_SUCCESS, false)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment