I’m trying to figure out how to do this:
`
trait RestfulService {
def method : String
…
protected def GET = … // returns HttpRequestBuilder
protected def PUT = …
protected def POST = … // returns HttpRequestWithParamsBuilder
protected def formPOST = …
protected def DELETE = …
protected def HEAD = …
def request = method match {
case “GET” => this.GET
case “PUT” => this.PUT
case “POST” => this.POST
case “formPOST” => this.formPOST
case “DELETE” => this.DELETE
case “HEAD” => this.HEAD
case s => throw new Error( "Unexpected request method: " + s )
}
}
`
Then
trait RtdeService extends RestfulService { ... def request = if ( Config.Endpoint.Services.config.getBoolean( "layer7" ) ) super.request .queryParam( "access_token", ACCESS_TOKEN.value ) else super.request .header( "o2_client_id", CLIENT_ID.value ) .header( "o2_scope", CLIENT_SCOPE.value ) .header( "o2_individual_id", USER_NAME.value ) .header( "Cache-Control", "no-cache" ) }
I get a type mismatch on the RtdeService request method at the super.request lines that looks something mind-bending, like this:
`
type mismatch; found : _11 where
type _11 >: io.gatling.http.request.builder.HttpRequestBuilder
with io.gatling.http.request.builder.HttpRequestWithParamsBuilder
<: io.gatling.http.request.builder.AbstractHttpRequestBuilder[
_ >: io.gatling.http.request.builder.HttpRequestBuilder
with io.gatling.http.request.builder.HttpRequestWithParamsBuilder
<: com.typesafe.scalalogging.slf4j.StrictLogging]
required: io.gatling.http.request.builder.AbstractHttpRequestBuilder[
? >: io.gatling.http.request.builder.HttpRequestBuilder
with io.gatling.http.request.builder.HttpRequestWithParamsBuilder
<: io.gatling.http.request.builder.AbstractHttpRequestBuilder[
_ >: io.gatling.http.request.builder.HttpRequestBuilder
with io.gatling.http.request.builder.HttpRequestWithParamsBuilder
<: com.typesafe.scalalogging.slf4j.StrictLogging]]
Note: com.typesafe.scalalogging.slf4j.StrictLogging
: ? >: io.gatling.http.request.builder.HttpRequestBuilder
with io.gatling.http.request.builder.HttpRequestWithParamsBuilder
<: io.gatling.http.request.builder.AbstractHttpRequestBuilder[
_ >: io.gatling.http.request.builder.HttpRequestBuilder
with io.gatling.http.request.builder.HttpRequestWithParamsBuilder
<: com.typesafe.scalalogging.slf4j.StrictLogging]
(and _11 <: io.gatling.http.request.builder.AbstractHttpRequestBuilder[
_ >: io.gatling.http.request.builder.HttpRequestBuilder
with io.gatling.http.request.builder.HttpRequestWithParamsBuilder
<: com.typesafe.scalalogging.slf4j.StrictLogging]),
but class AbstractHttpRequestBuilder is invariant in type B. You may wish to define B as -B instead. (SLS 4.5)
`
I’ve experimented with many different ways of doing the type declaration, but I have not hit upon the right way to do it. Any ideas?
`
`