reactormonk
02/14/2023, 10:28 AMval reqF = RequestFilters.Tap { Log.d("request", it.toString()) }
, but wrapping that around the client doesn't do it. https://www.http4k.org/guide/howto/structure_your_logs_with_events/ seems to be responses onlydave
02/14/2023, 10:33 AMDebuggingFilters.PrintRequestAndResponse()
, or just handler.debug()
. But I'm more interested that you're having problems making the filters work - because we use this type of thing heavily and it very much does! 😉
Can you put a small example together to demonstrate the problem?reactormonk
02/14/2023, 10:41 AMdave
02/14/2023, 10:42 AMprivate val browser = FollowRedirects()
.then(Cookies())
.then(// insert tap here //)
.then(http)
reactormonk
02/14/2023, 11:04 AMruby
page = agent.get (base + "/login")
login_form = page.form_with(action: base + "/login")
login_form.field_with(id: "login").value = username
login_form.add_field!("password", password)
http4k
kotlin
private val browser = ClientFilters.FollowRedirects()
.then(ClientFilters.Cookies())
.then(DebuggingFilters.PrintRequestAndResponse())
.then(ClientFilters.AcceptGZip())
.then(client)
val loginRequest = Request(Method.GET, uri.appendToPath("/login"))
val loginResponse = browser(loginRequest)
val loginParsed = loginResponse.parsed()
val csrf = loginParsed.select("meta[name=csrf-token]").firstOrNull()?.attr("content")
Log.d("csrf", "$csrf")
val dashboardRequest = Request(<http://Method.POST|Method.POST>, uri.appendToPath("/login"))
.form("login", credentials.username)
.form("password", credentials.password)
.form("_token", csrf!!)
val dashboardResponse = browser(dashboardRequest)
if (dashboardResponse.status != Status.OK) {
throw Exception("Login didn't work")
}