Skip to content

Instantly share code, notes, and snippets.

@aartajew
Last active June 20, 2023 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aartajew/3958dc76856d42e982f797b3930247f8 to your computer and use it in GitHub Desktop.
Save aartajew/3958dc76856d42e982f797b3930247f8 to your computer and use it in GitHub Desktop.
Gatling > Parse Expression Language string
package util
import io.gatling.core.session._
object ElParser {
def apply[T](expression: Expression[T], session: Session): T = toOption(expression, session).get
def toOption[T](expression: Expression[T], session: Session): Option[T] = expression(session).toOption
}
// usage
val expression: Expression[String] = "#{sessionId}"
val sessionId = ElParser(expression, session)
// type hinting
val userId = ElParser[String]("#{userId}", session)
val userData = ElParser[Map[String, Any]]("#{userData}", session)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment