本文整理汇总了Java中com.mashape.unirest.http.HttpMethod.PUT属性的典型用法代码示例。如果您正苦于以下问题:Java HttpMethod.PUT属性的具体用法?Java HttpMethod.PUT怎么用?Java HttpMethod.PUT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.mashape.unirest.http.HttpMethod
的用法示例。
在下文中一共展示了HttpMethod.PUT属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: httpPut
public static HttpTestRequest httpPut(String request, String body) {
return new HttpTestRequest(HttpMethod.PUT, request, body, HttpTestRequest.ResponseType.Json);
}