===== Hidden Method

The javadoc:Router[setHiddenMethod, java.lang.String] option allows clients to override the HTTP method. This is especially useful for HTML forms, which natively only support `GET` and `POST`.

.Client
[source, html]
----
<form method="post" action="/form">
  <input type="hidden" name="_method" value="put">
</form>
----

.Server
[source, java, role = "primary"]
----
import io.jooby.Jooby;
...
{
  setHiddenMethod("_method"); // <1>

  put("/form", ctx -> {       // <2>
    return "Updated!";
  });
}
----

.Kotlin
[source, kotlin, role = "secondary"]
----
import io.jooby.Jooby
...
{
  setHiddenMethod("_method")  // <1>
  
  put("/form") {              // <2>
    "Updated!"
  }
}
----

<1> Configures the router to look for a form field named `_method`.
<2> Executes the `PUT` handler for `/form` instead of the standard `POST`.

*(Note: I fixed a small bug in your Kotlin snippet where you were using Java lambda syntax inside the `put` route).*

The default implementation looks for the specified hidden field in `POST` forms or multipart requests. Alternatively, you can provide a custom strategy, such as reading an HTTP header:

.HTTP Header Strategy
[source, java, role = "primary"]
----
import io.jooby.Jooby;
...
{
  setHiddenMethod(ctx -> ctx.header("X-HTTP-Method-Override").toOptional()); // <1>
}
----

.Kotlin
[source, kotlin, role = "secondary"]
----
import io.jooby.Jooby
...
{
  setHiddenMethod { ctx -> ctx.header("X-HTTP-Method-Override").toOptional() } // <1>
}
----

<1> Overrides the HTTP method by extracting it from the `X-HTTP-Method-Override` request header.
