+htc add starting points for requests with a certain HTTP method

This commit is contained in:
Johannes Rudolph 2014-11-26 10:33:58 +01:00
parent 80f125f481
commit 0859c5cadc
3 changed files with 54 additions and 8 deletions

View file

@ -44,9 +44,51 @@ public abstract class HttpRequest implements HttpMessage, HttpMessage.MessageTra
public abstract HttpRequest withEntity(RequestEntity entity);
/**
* Returns a default request to be changed using the `withX` methods.
* Returns a default request to be modified using the `withX` methods.
*/
public static HttpRequest create() {
return Accessors$.MODULE$.HttpRequest();
return Accessors.HttpRequest();
}
/**
* Returns a default request to the specified URI to be modified using the `withX` methods.
*/
public static HttpRequest create(String uri) {
return Accessors.HttpRequest(uri);
}
/**
* A default GET request to be modified using the `withX` methods.
*/
public static HttpRequest GET(String uri) {
return create(uri);
}
/**
* A default POST request to be modified using the `withX` methods.
*/
public static HttpRequest POST(String uri) {
return create(uri).withMethod(HttpMethods.POST);
}
/**
* A default PUT request to be modified using the `withX` methods.
*/
public static HttpRequest PUT(String uri) {
return create(uri).withMethod(HttpMethods.PUT);
}
/**
* A default DELETE request to be modified using the `withX` methods.
*/
public static HttpRequest DELETE(String uri) {
return create(uri).withMethod(HttpMethods.DELETE);
}
/**
* A default HEAD request to be modified using the `withX` methods.
*/
public static HttpRequest HEAD(String uri) {
return create(uri).withMethod(HttpMethods.HEAD);
}
}

View file

@ -37,6 +37,6 @@ public abstract class HttpResponse implements HttpMessage, HttpMessage.MessageTr
* Returns a default response to be changed using the `withX` methods.
*/
public static HttpResponse create() {
return Accessors$.MODULE$.HttpResponse();
return Accessors.HttpResponse();
}
}

View file

@ -12,12 +12,16 @@ import akka.stream.MaterializerSettings
*
* Accessors for constructors with default arguments to be used from the Java implementation
*/
private[http] object Accessors {
object Accessors {
/** INTERNAL API */
private[http] def HttpRequest(): HttpRequest = model.HttpRequest()
/** INTERNAL API */
private[http] def HttpResponse(): HttpResponse = model.HttpResponse()
def HttpRequest(): HttpRequest = model.HttpRequest()
/** INTERNAL API */
private[http] def Uri(uri: model.Uri): Uri = JavaUri(uri)
def HttpRequest(uri: String): HttpRequest = model.HttpRequest(uri = uri)
/** INTERNAL API */
def HttpResponse(): HttpResponse = model.HttpResponse()
/** INTERNAL API */
def Uri(uri: model.Uri): Uri = JavaUri(uri)
}