formParam is not a member of type parameter T ... ???

I’m trying to extend the DSL for http() just to make more readable code. But I appear to be doing it wrong, somehow…

implicit class HttpRequestExtensions[T <: AbstractHttpRequestBuilder[T]] ( request: T ) {
def clientAuth =
.queryParam( “client_id”, CLIENT_ID.value )
.queryParam( “scope”, CLIENT_SCOPE.value )
.queryParam( “response_type”, “code” )
.queryParam( “redirect_uri”, CLIENT_REDIRECT.value )
.queryParam( “state”, “init” )

def clientParams =
.queryParam( “nonce”, NONCE.value )
.queryParam( “display”, “page” )
.queryParam( “prompt”, “login” )

def loginCredentials =
.headers( Headers.formPost )
.formParam( “session”, SESSION_ID.value )
.formParam( “username”, USER_NAME.value )
.formParam( “password”, PASSWORD.value )
.formParam( “action”, “login” )


The compiler has no problem with the first two methods, but complains about .formParam() in the third. Any idea what I might have done wrong?

I mis-understood what was going on under the covers… Learning new things about scala every day!

I thought T was any type that is a sub-type of AbstractHttpRequestBuilder[T]. Thanks to a co-worker, I now understand that what it actually means is: I am declaring T as any sub-type of AbstractHttpRequestBuilder, but I am only using those parts defined in AbstractHttpRequestBuilder[T]. Hence, the compiler complaining about .formParam not being defined. I get it, now.

I broke out those parts that are specific to HttpRequestWithParamsBuilder into their own implicit, and it now compiles just fine. :slight_smile:

Exactly :slight_smile:

Sorry for the late reply.