@@ -44,12 +44,15 @@ registry while the request it belongs to is being processed.
4444
4545=== Parameters
4646
47- There are several parameter types: `header`, `cookie`, `path`, `query`, `form` and `multipart`.
48- All them share an unified/type-safe API for accessing and manipulating their values.
47+ There are several parameter types: `header`, `cookie`, `path`, `query`, `form`, `multipart`,
48+ `session` and `flash`. All them share a unified/type-safe API for accessing and manipulating their values.
4949
5050We are going to describe them briefly in the next sections, then go into specific features of the
5151<<Value API>>.
5252
53+ There is also a <<context-parameters-parameter-lookup,parameter lookup>> feature by which you can access a parameter from any combination
54+ of the above types with well-defined priority.
55+
5356==== Header
5457
5558HTTP headers allow the client and the server to pass additional information with the request or the
@@ -568,6 +571,41 @@ Flash attributes are implemented using an `HTTP Cookie`. To customize the cookie
568571 install(FlashScope(Cookie("myflash").setHttpOnly(true)))
569572----
570573
574+ ==== Parameter Lookup
575+
576+ You can search for parameters in multiple sources with an explicitly defined priority using the
577+ javadoc:Context[lookup] or javadoc:Context[lookup, java.lang.String, ParamSource...] method:
578+
579+ .Java
580+ [source,java,role="primary"]
581+ ----
582+ get("/{foo}", ctx -> {
583+ String foo = ctx.lookup("foo", ParamSource.QUERY, ParamSource.PATH).value();
584+ return "foo is: " + foo;
585+ });
586+
587+ get("/{foo}", ctx -> {
588+ String foo = ctx.lookup().inQuery().inPath().get("foo").value();
589+ return "foo is: " + foo;
590+ });
591+ ----
592+
593+ .Kotlin
594+ [source,kotlin,role="secondary"]
595+ ----
596+ get("/{foo}") { ctx ->
597+ val foo = ctx.lookup("foo", ParamSource.QUERY, ParamSource.PATH).value()
598+ "foo is: $foo"
599+ }
600+
601+ get("/{foo}") { ctx ->
602+ val foo = ctx.lookup().inQuery().inPath()["foo"].value()
603+ "foo is: $foo"
604+ }
605+ ----
606+
607+ In case of a request like `/bar?foo=baz`, `foo is: baz` will be returned since the query parameter
608+ takes precedence over the path parameter.
571609
572610include::value-api.adoc[]
573611
0 commit comments