Normally we bind inside a with method call. Try ca...
# http4k
d
Normally we bind inside a with method call. Try calling it with the parens instead of infixed?
e
Same problem...
d
looks like it only works if you specify the input type
Copy code
val hello = Header.required("foo").of<HttpMessage>("baa")
e
It did the trick. Now, how can solve this: I have
Copy code
("/api/v1/${this.path.format(param)}" bindContract GET).let { route: RouteBinder<HttpHandler> ->
                handler.perform(route.newRequest().with(
                        Header.required("Service-Provider-Id") of "my-provider",
                        Header.required("Client-Realm-Id") of catalogName
                  ), this.responseLens as BodyLens<T>
                )
            }
I'd like to have:
Copy code
fun <T : HttpMessage> serviceProviderIDOf(x: String) = Header.required("Service-Provider-Id").of<T>(x)

val setServiceProviderId = Filter { next ->
    { next(it).with(serviceProviderIDOf("myval")) }
}

    operator fun <T> invoke(handler: HttpHandler, catalogName: String, param: String): Pair<Status, T> =
            ("/api/v1/${this.path.format(param)}" bindContract GET).then(setServiceProviderId).let { route: RouteBinder<HttpHandler> ->
                handler.perform(route.newRequest().with(
                        Header.required("Client-Realm-Id") of catalogName
                  ), this.responseLens as BodyLens<T>
                )
            }
But it doesn't compile...
d
I think you're a little mixed up. bindContract doesn't return anything you can "then" to
e
yep, I'm a bit confused
d
bindContract will bind to a function that takes a string and returns an HttpHandler. so you need to attach filters to the response of that handler
e
I see...
The filter I created should be used to add a header to the request.
d
And you'll need to add it everytime - the bond method expects a function that returns a(decorated) httphandler
e
Didn't manage to make it work... will skip it for now