How to use doIf action in resources section

Hi, I wonder how I can use a non mandatory action in resources section. The case is the following:

`
val bar = doIf(session => session.contains(“bar”)) {
exec(
http(“GET /bar”)
.get("/bar")
)
}

val foo = http("/foo")
.get("/foo")
.resources(
bar // Here is an error - Type mismаtch, expected: HttрRequestBuilder, actual: ChаinBuildеr
)
`

Is it possible to rewrite this piece of code, so I could achieve the desired behaviour?

TIA.