本文整理汇总了Java中io.vertx.ext.web.RoutingContext.response方法的典型用法代码示例。如果您正苦于以下问题:Java RoutingContext.response方法的具体用法?Java RoutingContext.response怎么用?Java RoutingContext.response使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.ext.web.RoutingContext
的用法示例。
在下文中一共展示了RoutingContext.response方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendFile
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
private void sendFile(RoutingContext routingContext, String fileName, File saneFile) {
HttpServerResponse response = routingContext.response();
response.putHeader("Content-Description", "File Transfer");
response.putHeader("Content-Type", "application/octet-stream");
response.putHeader("Content-Disposition", "attachment; filename=" + fileName); // @TODO: don't trust this name?
response.putHeader("Content-Transfer-Encoding", "binary");
response.putHeader("Expires", "0");
response.putHeader("Pragma", "Public");
response.putHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
response.putHeader("Content-Length", "" + saneFile.length());
response.sendFile(saneFile.getAbsolutePath());
}
示例2: handle
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
public void handle(RoutingContext ctx)
{
HttpServerResponse response = ctx.response();
if(userManager.isLogined(ctx)){
try {
String uid = userManager.getUid(userManager.getIdFromSession(ctx));
String result = requestManager.createApiKey(uid);
if(result != null){
response.setStatusCode(200);
response.setStatusMessage(result);
}
} catch (SQLException e) {
e.printStackTrace();
response.setStatusCode(500);
}
}else{
response.setStatusCode(400);
}
response.end();
response.close();
}
示例3: reply
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
public static void reply(
final RoutingContext context,
final Envelop envelop,
final Event event
) {
// 1. Get response reference
final HttpServerResponse response
= context.response();
// 2. Set response status
final HttpStatusCode code = envelop.status();
response.setStatusCode(code.code());
response.setStatusMessage(code.message());
// 3. Media processing
Normalizer.out(response, envelop, event);
// 4. Store Session
storeSession(context, envelop.data(), event.getAction());
// 5. Response process
if (!response.ended()) {
response.end(envelop.response());
}
response.close();
}
示例4: handle
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
@Override
public void handle(RoutingContext routingContext) {
HttpServerResponse response = routingContext.response();
response.putHeader("Content-Type", "application/json").setChunked(true);
response.write(new Response().getResponse(Constants.GET_STACK_RESPONSE_TEMPLATE));
response.end();
}
示例5: onFailure
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
protected void onFailure(RoutingContext context) {
LOGGER.error("edge server failed.", context.failure());
HttpServerResponse response = context.response();
response.setStatusCode(Status.BAD_GATEWAY.getStatusCode());
response.setStatusMessage(Status.BAD_GATEWAY.getReasonPhrase());
response.end();
}
示例6: init
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
public void init(String microserviceName, RoutingContext context, String path,
List<HttpServerFilter> httpServerFilters) {
this.microserviceName = microserviceName;
this.requestEx = new VertxServerRequestToHttpServletRequest(context, path);
this.responseEx = new VertxServerResponseToHttpServletResponse(context.response());
this.httpServerFilters = httpServerFilters;
requestEx.setAttribute(RestConst.REST_REQUEST, requestEx);
}
示例7: onFailure
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
@Test
public void onFailure(@Mocked RoutingContext context) {
Map<String, Object> map = new HashMap<>();
HttpServerResponse response = new MockUp<HttpServerResponse>() {
@Mock
HttpServerResponse setStatusCode(int statusCode) {
map.put("code", statusCode);
return null;
}
@Mock
HttpServerResponse setStatusMessage(String statusMessage) {
map.put("msg", statusMessage);
return null;
}
}.getMockInstance();
new Expectations() {
{
context.failure();
returns(new Error("failed"), null);
context.response();
result = response;
}
};
AbstractEdgeDispatcherForTest dispatcher = new AbstractEdgeDispatcherForTest();
dispatcher.onFailure(context);
Assert.assertEquals(502, map.get("code"));
Assert.assertEquals("Bad Gateway", map.get("msg"));
}
示例8: handle
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
@Override
public void handle(RoutingContext routingContext) {
HttpServerResponse response = routingContext.response();
response.putHeader("Content-Type", "application/json").setChunked(true);
response.write(new Response().getResponse(Constants.CREATE_PROJECT_RESPONSE_TEMPLATE));
response.end();
}
示例9: handle
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
@Override
public void handle(RoutingContext routingContext) {
HttpServerResponse response = routingContext.response();
response.putHeader("Content-Type", "application/json").setChunked(true);
response.write(new Response().getResponse(Constants.GET_WORKSPACE_BY_ID_RESPONSE_TEMPLATE));
response.end();
}
示例10: oauthBaseCallback
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
/**
* 支付宝静默授权的回调方法
* 由支付宝服务器调用
*
* @param rc Vertx的RoutingContext对象
* @author Leibniz.Hu
*/
private void oauthBaseCallback(RoutingContext rc) {
HttpServerRequest req = rc.request();
HttpServerResponse resp = rc.response();
Integer eid = Integer.parseInt(req.getParam("eid"));
getAccountAndExecute(resp, eid, aliAcc -> {
AlipaySystemOauthTokenResponse oauthRes = AliPayApi.getUserId(aliAcc, req);
oauthSuccessProcess(req, resp, oauthRes, url -> log.info("授权成功,OpenID={},{},准备跳转到{}", oauthRes.getUserId(), oauthRes.getAlipayUserId(), url));
});
}
示例11: handle
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
@Override
public void handle(RoutingContext routingContext) {
HttpServerResponse response = routingContext.response();
response.putHeader("Content-Type", "application/json").setChunked(true);
response.write(new Response().getResponse(Constants.GET_WORKSPACE_RESPONSE_TEMPLATE));
response.end();
}
示例12: handle
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
@Override
public void handle(RoutingContext routingContext) {
HttpServerResponse response = routingContext.response();
response.putHeader("Content-Type", "application/json").setChunked(true);
response.write(new Response().getResponse(Constants.CREATE_WORKSPACE_RESPONSE_TEMPLATE));
response.end();
}
示例13: handle
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
@Override
public void handle(RoutingContext routingContext) {
HttpServerResponse response = routingContext.response();
response.putHeader("Content-Type", "application/json").setChunked(true);
if (routingContext.request().getHeader("Authorization").contains(Properties.DEFAULT_GITHUB_TOKEN)) {
response.write("{ \"name\":\"Marian Labuda\", \"email\":\"[email protected]\"}");
} else {
response.write("{\"errorMessage\":\"Invalid token.\"}");
response.setStatusCode(400);
}
response.end();
}
示例14: forwardErrorCode
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
private void forwardErrorCode(RoutingContext routingContext, AsyncResult<Message<Object>> reply) {
ReplyException ex = (ReplyException) reply.cause();
ex.printStackTrace();
HttpServerResponse response = routingContext.response();
response.setStatusCode(ex.failureCode());
response.end();
}
示例15: ingest
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
@Override
public Epsilon<T> ingest(final RoutingContext context,
final Epsilon<T> income)
throws WebException {
Object returnValue = null;
final Class<?> paramType = income.getArgType();
if (is(Session.class, paramType)) {
// Session Object
returnValue = context.session();
} else if (is(HttpServerRequest.class, paramType)) {
// Request Object
returnValue = context.request();
} else if (is(HttpServerResponse.class, paramType)) {
// Response Object
returnValue = context.response();
} else if (is(Vertx.class, paramType)) {
// Vertx Object
returnValue = context.vertx();
} else if (is(EventBus.class, paramType)) {
// Eventbus Object
returnValue = context.vertx().eventBus();
} else if (is(User.class, paramType)) {
// User Objbect
returnValue = context.user();
} else if (is(Set.class, paramType)) {
// FileUpload
final Class<?> type = paramType.getComponentType();
if (is(FileUpload.class, type)) {
returnValue = context.fileUploads();
}
} else if (is(JsonArray.class, paramType)) {
// JsonArray
returnValue = context.getBodyAsJsonArray();
} else if (is(JsonObject.class, paramType)) {
// JsonObject
returnValue = context.getBodyAsJson();
} else if (is(Buffer.class, paramType)) {
// Buffer
returnValue = context.getBody();
}
return null == returnValue ? income.setValue(null) : income.setValue((T) returnValue);
}