本文整理汇总了Java中com.mashape.unirest.http.HttpMethod.POST属性的典型用法代码示例。如果您正苦于以下问题:Java HttpMethod.POST属性的具体用法?Java HttpMethod.POST怎么用?Java HttpMethod.POST使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.mashape.unirest.http.HttpMethod
的用法示例。
在下文中一共展示了HttpMethod.POST属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mapToUnirestHttpMethod
public static HttpMethod mapToUnirestHttpMethod(drinkwater.rest.HttpMethod methodAsAnnotation) {
switch (methodAsAnnotation.value().toUpperCase()) {
case "GET":
return HttpMethod.GET;
case "POST":
return HttpMethod.POST;
case "DELETE":
return HttpMethod.DELETE;
case "PUT":
return HttpMethod.PUT;
case "PATCH":
return HttpMethod.PATCH;
default:
throw new RuntimeException(String.format("could not map correct http method : %s", methodAsAnnotation.value()));
}
}
示例2: routesWithoutPathArg_works
@Test
public void routesWithoutPathArg_works() throws Exception {
app.routes(() -> {
path("api", () -> {
get(OK_HANDLER);
post(OK_HANDLER);
put(OK_HANDLER);
delete(OK_HANDLER);
patch(OK_HANDLER);
path("user", () -> {
get(OK_HANDLER);
post(OK_HANDLER);
put(OK_HANDLER);
delete(OK_HANDLER);
patch(OK_HANDLER);
});
});
});
HttpMethod[] httpMethods = new HttpMethod[]{HttpMethod.GET, HttpMethod.POST, HttpMethod.PUT, HttpMethod.DELETE, HttpMethod.PATCH};
for (HttpMethod httpMethod : httpMethods) {
assertThat(call(httpMethod, "/api").getStatus(), is(200));
assertThat(call(httpMethod, "/api/user").getStatus(), is(200));
}
}
示例3: toRestdefinition
private static RestDefinition toRestdefinition(RouteBuilder builder,
Method method,
HttpMethod httpMethod,
String restPath) {
RestDefinition answer = builder.rest();
String fromPath = restPath;
if (httpMethod == HttpMethod.GET) {
answer = answer.get(fromPath);
} else if (httpMethod == HttpMethod.POST) {
answer = answer.post(fromPath);
} else if (httpMethod == HttpMethod.PUT) {
answer = answer.put(fromPath);
} else if (httpMethod == HttpMethod.DELETE) {
answer = answer.delete(fromPath);
} else if (httpMethod == HttpMethod.PATCH) {
answer = answer.patch(fromPath);
} else {
throw new RuntimeException("method currently not supported in Rest Paths : " + httpMethod);
}
answer = setBodyType(answer, method);
return answer;
}
示例4: init
private void init() {
HttpMethod httpMethod = httpMethodFor(method);
List<Parameter> parameterInfos = javaslang.collection.List.of(method.getParameters());
NoBody noBodyAnnotation = method.getAnnotation(NoBody.class);
hasReturn = returnsVoid(method);
if (parameterInfos.size() == 0) {
return;
}
if (httpMethod == HttpMethod.GET) {
hasBody = false;
} else if (httpMethod == HttpMethod.POST || httpMethod == HttpMethod.DELETE || httpMethod == HttpMethod.PUT) {
if (parameterInfos.size() > 0) {
hasBody = true;
}
if (noBodyAnnotation != null) {
hasBody = false;
}
} else {
throw new RuntimeException("come back here : MethodToRestParameters.init()");
}
if (hasBody) { // first parameter of the method will be assigned with the body content
headerNames = parameterInfos.tail().map(p -> mapName(p)).toList();
} else {
headerNames = parameterInfos.map(p -> mapName(p)).toList();
}
}
示例5: httpPost
public static HttpTestRequest httpPost(String request, String body) {
return new HttpTestRequest(HttpMethod.POST, request, body, HttpTestRequest.ResponseType.Json);
}
示例6: httpPostFile
public static HttpTestRequest httpPostFile(String request, InputStream is, Class responseType, Map<String, String> headers) {
return new HttpTestRequest(HttpMethod.POST, request, is, HttpTestRequest.ResponseType.Object, responseType, headers);
}
示例7: httpPostRequestString
public static HttpTestRequest httpPostRequestString(String request, String body) {
return new HttpTestRequest(HttpMethod.POST, request, body, HttpTestRequest.ResponseType.String);
}
示例8: generateFirstTimeSwaggerFile
private Swagger generateFirstTimeSwaggerFile(EndpointResponse response) {
SwaggerBuilder swaggerBuilder = new SwaggerBuilder();
swaggerBuilder.withHost(mUserInput.getHost());
swaggerBuilder.withBasePath(mUserInput.getBasePath());
swaggerBuilder.withInfo().withTitle("Title").withVersion("1.0");
OperationBuilder opBuilder;
if (mUserInput.getMethod() == HttpMethod.GET) {
opBuilder = swaggerBuilder.withPath(mUserInput.getApiPath()).withGet();
} else if (mUserInput.getMethod() == HttpMethod.POST) {
opBuilder = swaggerBuilder.withPath(mUserInput.getApiPath()).withPost();
} else if (mUserInput.getMethod() == HttpMethod.DELETE) {
opBuilder = swaggerBuilder.withPath(mUserInput.getApiPath()).withDelete();
} else {
opBuilder = swaggerBuilder.withPath(mUserInput.getApiPath()).withPut();
}
opBuilder.withSummary(mUserInput.getApiSummary())
.withDescription(mUserInput.getApiDescription())
.withTags(mUserInput.getApiTags());
populatePathParameters(opBuilder, URLUtils.parsePathParameters(mUserInput.getEndpoint()));
populateQueryParameters(opBuilder, mUserInput.getParameters());
String firstMimeType = HttpUtils.getFirstMimeType(response);
if (StringUtils.isBlank(firstMimeType)) {
logger.info("no mime type to populate in response's produce section, it is recommended to emit content-type header in response. Continuing further for building swagger json..");
} else {
opBuilder.withProduceMimeType(firstMimeType);
}
ResponseBuilder responseBuilder = new ResponseBuilder();
responseBuilder.withDescription(response.getStatusText());
if (MimeType.JSON.getName().equals(firstMimeType) || MimeType.XML.getName().equals(firstMimeType)) {
responseBuilder.withSchema(new RefPropertyBuilder().withReferenceTo(mUserInput.getApiName()));
populateModels(response, swaggerBuilder);
} else if (MimeType.ZIP.getName().equals(firstMimeType) || MimeType.OCTETSTREAM.getName().equals(firstMimeType)) {
responseBuilder.withSchema(new FilePropertyBuilder());
}
opBuilder.withResponse(String.valueOf(response.getStatus()), responseBuilder);
return swaggerBuilder.build();
}
示例9: getMethod
@Override
public HttpMethod getMethod() {
return HttpMethod.POST;
}