public class Requests extends Object
| Constructor and Description |
|---|
Requests() |
| Modifier and Type | Method and Description |
|---|---|
static mjson.Json |
extractJsonField(mjson.Json json,
String... fieldPath)
Given a
Json object, attempt to extract a single field as supplied,
or throw a user-friendly exception clearly indicating the missing field |
static String |
mandatoryBody(spark.Request request)
Given a {@link Request), retreive the value of the request body.
|
static String |
mandatoryPathParameter(spark.Request request,
String parameter)
Given a
Function, retrieve the value of the by applying that function |
static <T> T |
mandatoryQueryParameter(java.util.function.Function<String,Optional<T>> extractParameterFunction,
String parameter)
Given a
Function, retrieve the value of the by applying that function |
static String |
mandatoryQueryParameter(spark.Request request,
String parameter)
Given a
Request object retrieve the value of the argument. |
static Optional<String> |
queryParameter(spark.Request request,
String parameter)
Given a
Request, retrieve the value of the |
public static String mandatoryQueryParameter(spark.Request request, String parameter)
Request object retrieve the value of the argument. If it is not present
in the request query, return a 400 to the client.request - information about the HTTP requestparameter - value to retrieve from the HTTP requestpublic static <T> T mandatoryQueryParameter(java.util.function.Function<String,Optional<T>> extractParameterFunction, String parameter)
Function, retrieve the value of the by applying that functionextractParameterFunction - function used to extract the parameterparameter - value to retrieve from the HTTP requestpublic static Optional<String> queryParameter(spark.Request request, String parameter)
Request, retrieve the value of the request - information about the HTTP requestparameter - value to retrieve from the HTTP requestpublic static String mandatoryBody(spark.Request request)
request - information about the HTTP requestpublic static String mandatoryPathParameter(spark.Request request, String parameter)
Function, retrieve the value of the by applying that functionextractParameterFunction - function used to extract the parameterparameter - value to retrieve from the HTTP requestpublic static mjson.Json extractJsonField(mjson.Json json,
String... fieldPath)
Json object, attempt to extract a single field as supplied,
or throw a user-friendly exception clearly indicating the missing fieldjson - the Json object containing the field to be extractedfieldPath - String varargs representing the path of the field to be extractedJson object{@link - GraknServerException} with a clear indication of the missing fieldCopyright © 2017 Grakn Labs Ltd. All rights reserved.