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”)) {
http(“GET /bar”)

val foo = http("/foo")
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?