Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2020 Yak.Works - Licensed under the Apache License, Version 2.0 (the "License")
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/
package yakworks.rest.client
import java.nio.charset.StandardCharsets
import java.time.Duration
import groovy.transform.CompileDynamic
import groovy.transform.CompileStatic
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Value
import org.springframework.http.HttpHeaders
import org.springframework.http.HttpMethod
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.http.client.reactive.ReactorClientHttpConnector
import org.springframework.web.reactive.function.client.WebClient
import org.springframework.web.util.UriUtils
import reactor.netty.http.client.HttpClient
import yakworks.commons.lang.EnumUtils
import yakworks.json.groovy.JsonEngine
import static org.springframework.web.reactive.function.client.WebClient.Builder
import static org.springframework.web.reactive.function.client.WebClient.ResponseSpec
/**
* Trait with helper methods to wrap OKHttps HttpClient for rest api testing
*/
@CompileStatic
//@CompileDynamic
trait WebClientTrait {
@Autowired Builder wbuilder
String jsonHeader = "application/json;charset=utf-8"
@Value('${spring.security.user.name:admin}')
String username
@Value('${spring.security.user.password:123}')
String password
/**
* Main method to fire a request and get a response.
* builds request and executes it with the OkHttpclient.
* @param method - POST, PUT, GET, DELETE, PATCH, etc..
* @param uriPath - the path, will call getUrl to append baseUrl if doesnt start with http
* @param body - the body object to convert to json, usually a Map or sometimes List
* @return the ResponseEntity
*/
ResponseEntity