当前位置: 首页>>代码示例>>Java>>正文


Java HttpMethod.PUT属性代码示例

本文整理汇总了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()));
    }
}
 
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:16,代码来源:RestHelper.java

示例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));
    }
}
 
开发者ID:tipsy,项目名称:javalin,代码行数:24,代码来源:TestApiBuilder.java

示例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;
}
 
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:26,代码来源:RestHelper.java

示例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();
    }

}
 
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:32,代码来源:MethodToRestParameters.java

示例5: httpPut

public static HttpTestRequest httpPut(String request, String body) {
    return new HttpTestRequest(HttpMethod.PUT, request, body, HttpTestRequest.ResponseType.Json);
}
 
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:3,代码来源:HttpUnitTest.java


注:本文中的com.mashape.unirest.http.HttpMethod.PUT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。