Part of the main html response is a json blob. Using the check() I have saved the json blob as a string in the session. I then deserialized that json blob into a class/object, which I then stored in the session. Now I need to build a url for a subsequent http().get(), using a value within the object from the deserialized json.
How do I build the proper url in .resources(http().get())?
exec(http("Go Home")
.get("/home")
.check(regex("my awesome regex to extract json").saveAs("jsonBlob"))
.resources(http("Home CSS")
.get("/css/home_${state.version}.css")) // <- this is the part I need help with
)
.exec { session =>
val state:SiteState = SiteState.parse(session.get("jsonBlob").as[String])
session.set("state", state)
}
Here is the code for SiteState, if it matters
import com.google.gson.Gson
case class SiteState() {
var version:String = ""
var otherValuableData:Long = -1L
}
object SiteState {
private val gson = new Gson
def parse(data:String): SiteState = {
gson.fromJson(data, classOf[SiteState])
}
}
Thanks!