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


Java HttpMethod.DELETE属性代码示例

本文整理汇总了Java中com.mashape.unirest.http.HttpMethod.DELETE属性的典型用法代码示例。如果您正苦于以下问题:Java HttpMethod.DELETE属性的具体用法?Java HttpMethod.DELETE怎么用?Java HttpMethod.DELETE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.mashape.unirest.http.HttpMethod的用法示例。


在下文中一共展示了HttpMethod.DELETE属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: httpDelete

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

示例6: 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();
	}
 
开发者ID:pegasystems,项目名称:api2swagger,代码行数:49,代码来源:SwaggerGenerator.java


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