Document HTTP custom method (#20508)
This commit is contained in:
parent
fb1905870c
commit
15c77e3392
10 changed files with 202 additions and 1 deletions
|
|
@ -42,6 +42,14 @@ public abstract class HttpMethod {
|
|||
|
||||
/**
|
||||
* Returns the entity acceptance level for this method.
|
||||
* @deprecated Use {@link #getRequestEntityAcceptance} instead, which returns {@link akka.http.javadsl.model.RequestEntityAcceptance}.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract akka.http.scaladsl.model.RequestEntityAcceptance requestEntityAcceptance();
|
||||
|
||||
/**
|
||||
* Java API: Returns the entity acceptance level for this method.
|
||||
*/
|
||||
// TODO: Rename it to requestEntityAcceptance() in Akka 3.0
|
||||
public abstract akka.http.javadsl.model.RequestEntityAcceptance getRequestEntityAcceptance();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,11 +27,24 @@ public final class HttpMethods {
|
|||
|
||||
/**
|
||||
* Create a custom method type.
|
||||
* @deprecated Use {@link #createCustom} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static HttpMethod custom(String value, boolean safe, boolean idempotent, akka.http.scaladsl.model.RequestEntityAcceptance requestEntityAcceptance) {
|
||||
return akka.http.scaladsl.model.HttpMethod.custom(value, safe, idempotent, requestEntityAcceptance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a custom method type.
|
||||
*/
|
||||
// TODO: Rename it to custom() in Akka 3.0
|
||||
public static HttpMethod createCustom(String value, boolean safe, boolean idempotent, akka.http.javadsl.model.RequestEntityAcceptance requestEntityAcceptance) {
|
||||
//This cast is safe as implementation of RequestEntityAcceptance only exists in Scala
|
||||
akka.http.scaladsl.model.RequestEntityAcceptance scalaRequestEntityAcceptance
|
||||
= (akka.http.scaladsl.model.RequestEntityAcceptance) requestEntityAcceptance;
|
||||
return akka.http.scaladsl.model.HttpMethod.custom(value, safe, idempotent, scalaRequestEntityAcceptance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks up a predefined HTTP method with the given name.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* Copyright (C) 2009-2016 Lightbend Inc. <http://www.lightbend.com>
|
||||
*/
|
||||
|
||||
package akka.http.javadsl.model;
|
||||
|
||||
/**
|
||||
* @see RequestEntityAcceptances for convenience access to often used values.
|
||||
* Do not extend this to a concrete Java class,
|
||||
* as implementation of RequestEntityAcceptation should only exist in Scala
|
||||
*/
|
||||
public abstract class RequestEntityAcceptance {
|
||||
public abstract boolean isEntityAccepted();
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* Copyright (C) 2009-2016 Lightbend Inc. <http://www.lightbend.com>
|
||||
*/
|
||||
|
||||
|
||||
package akka.http.javadsl.model;
|
||||
|
||||
public final class RequestEntityAcceptances {
|
||||
private RequestEntityAcceptances() {}
|
||||
|
||||
public static final RequestEntityAcceptance Expected = akka.http.scaladsl.model.RequestEntityAcceptance.Expected$.MODULE$;
|
||||
public static final RequestEntityAcceptance Tolerated = akka.http.scaladsl.model.RequestEntityAcceptance.Tolerated$.MODULE$;
|
||||
public static final RequestEntityAcceptance Disallowed = akka.http.scaladsl.model.RequestEntityAcceptance.Disallowed$.MODULE$;
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ import akka.http.impl.util._
|
|||
import akka.http.javadsl.{ model ⇒ jm }
|
||||
import akka.http.scaladsl.model.RequestEntityAcceptance._
|
||||
|
||||
sealed trait RequestEntityAcceptance {
|
||||
sealed trait RequestEntityAcceptance extends jm.RequestEntityAcceptance {
|
||||
def isEntityAccepted: Boolean
|
||||
}
|
||||
object RequestEntityAcceptance {
|
||||
|
|
@ -36,6 +36,7 @@ final case class HttpMethod private[http] (
|
|||
requestEntityAcceptance: RequestEntityAcceptance) extends jm.HttpMethod with SingletonValueRenderable {
|
||||
override def isEntityAccepted: Boolean = requestEntityAcceptance.isEntityAccepted
|
||||
override def toString: String = s"HttpMethod($value)"
|
||||
override def getRequestEntityAcceptance: jm.RequestEntityAcceptance = requestEntityAcceptance
|
||||
}
|
||||
|
||||
object HttpMethod {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue