com.jetdrone.vertx.yoke.middleware.MethodOverride Maven / Gradle / Ivy
/**
* Copyright 2011-2014 the original author or authors.
*/
package com.jetdrone.vertx.yoke.middleware;
import com.jetdrone.vertx.yoke.Middleware;
import org.jetbrains.annotations.NotNull;
import org.vertx.java.core.Handler;
import org.vertx.java.core.MultiMap;
import org.vertx.java.core.json.JsonObject;
/** # MethodOverride
*
* Pass an optional ```key``` to use when checking for a method override, othewise defaults to *_method* or the header
* *x-http-method-override*. The original method is available via ```req.originalMethod```.
*
* *note:* If the method override is sent in a *POST* then the [BodyParser](BodyParser.html) middleware must be used and
* installed prior this one.
*/
public class MethodOverride extends Middleware {
private final String key;
public MethodOverride(@NotNull final String key) {
this.key = key;
}
public MethodOverride() {
this("_method");
}
@Override
public void handle(@NotNull final YokeRequest request, @NotNull final Handler