本文整理汇总了Java中io.vertx.ext.web.RoutingContext.getCookie方法的典型用法代码示例。如果您正苦于以下问题:Java RoutingContext.getCookie方法的具体用法?Java RoutingContext.getCookie怎么用?Java RoutingContext.getCookie使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.ext.web.RoutingContext
的用法示例。
在下文中一共展示了RoutingContext.getCookie方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeCookieOrSession
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
public static void removeCookieOrSession(RoutingContext ctx, String key) {
if (ctx.session().get(key) != null) {
ctx.session().remove(key);
}
if (ctx.getCookie(key) != null) {
ctx.getCookie(key).setMaxAge(0);
}
}
示例2: getSessionId
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
public static String getSessionId(RoutingContext ctx, String key) {
String value = null;
if (ctx.session().get(key) != null) {
value = ctx.session().get(key);
} else if (ctx.getCookie(key) != null) {
value = ctx.getCookie(key).getValue();
}
return value;
}
示例3: apply
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
@Override
public Object apply(final String name,
final Class<?> paramType,
final RoutingContext context) {
final Cookie cookie = context.getCookie(name);
return cookie.getValue();
}
示例4: getRegistredSessionKey
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
public static String getRegistredSessionKey(RoutingContext context, String key) {
String sessionKey = null;
if (context.session() != null) {
sessionKey = context.session().get(key);
}
if (sessionKey == null && context.getCookie(key) != null) {
sessionKey = context.getCookie(key).getValue();
}
if (sessionKey != null && sessionKey.equals("null"))
sessionKey = null;
return sessionKey;
}
示例5: removeCookie
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
public static void removeCookie(RoutingContext context, String key) {
if (context.getCookie(key) != null) {
context.getCookie(key).setValue("null");
registerCookie(context, key, "null");
}
context.session().remove(key);
}
示例6: createCookie
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
public static void createCookie(RoutingContext ctx, String key, String value) {
// context에 쿠키 등록
if(ctx.getCookie(key) == null) {
Cookie cookie = Cookie.cookie(key, value);
cookie.setPath("/");
cookie.setMaxAge(60 * 60 * 24 * 365);
ctx.addCookie(cookie);
}
}
示例7: removeSession
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
public static void removeSession(RoutingContext ctx, String key) {
if(ctx.session().get(key) != null) {
ctx.session().remove(key);
}
if(ctx.getCookie(key) != null) {
ctx.getCookie(key).setMaxAge(0);
}
}
示例8: getClientSessionId
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
public static String getClientSessionId(RoutingContext ctx, String key) {
String value = null;
if(ctx.session().get(key) != null) {
value = ctx.session().get(key);
} else if(ctx.getCookie(key) != null) {
value = ctx.getCookie(key).getValue();
}
return value;
}
示例9: fromRoutingContext
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
public RequestContext fromRoutingContext(RoutingContext routingContext) {
RequestContext requestContext = new RequestContext();
requestContext.setUserAgent(RequestReader.getHeaderValue(routingContext, RequestReader.USER_AGENT_HEADER));
requestContext.setRequestUri(routingContext.request().uri());
requestContext.setRequestUrl(routingContext.request().absoluteURI());
requestContext.setRequestBody(routingContext.getBodyAsString());
requestContext.setHttpMethod(routingContext.request().method().toString());
Map<String, List<String>> headers = new HashMap<>();
// Don't want to propagate the Vert.x Multimap into the application code
routingContext.request().headers().forEach((entry) -> {
List<String> values = headers.get(entry.getKey());
if (values == null) {
values = new LinkedList<>();
headers.put(entry.getKey(), values);
}
values.add(entry.getValue());
});
requestContext.setHeaders(headers);
String limit = RequestReader.getQueryValue(routingContext, RequestReader.LIMIT_QUERY_PARAM);
if (limit != null && !limit.isEmpty()) {
requestContext.setLimit(Integer.parseInt(limit));
}
String offset = RequestReader.getQueryValue(routingContext, RequestReader.OFFSET_QUERY_PARAM);
if (offset != null && !offset.isEmpty()) {
requestContext.setOffset(Integer.parseInt(offset));
}
Cookie deviceIdCookie = routingContext.getCookie(RequestReader.DEVICE_ID);
if (deviceIdCookie != null) {
String deviceId = deviceIdCookie.getValue();
requestContext.setDeviceId(deviceId);
}
String authorizationHeaderValue = RequestReader.getHeaderValue(routingContext, RequestReader.AUTHORIZATION_HEADER);
if (authorizationHeaderValue != null && !authorizationHeaderValue.isEmpty()) {
try {
AuthorizationToken token = authorizationTokenFactory.fromAuthorizationHeader(authorizationHeaderValue);
requestContext.setAuthorizationToken(token);
} catch (Exception e) {
LOG.error("Could not parse authorization header", e);
}
}
return requestContext;
}
示例10: getCookieValue
import io.vertx.ext.web.RoutingContext; //导入方法依赖的package包/类
public static String getCookieValue(RoutingContext routingContext, String cookieName) {
LOG.debug("Reading cookie value [{}] from request", cookieName);
Cookie cookie = routingContext.getCookie(cookieName);
return cookie == null? null : cookie.getValue();
}