本文整理了Java中org.vertx.java.core.MultiMap.get()
方法的一些代码示例,展示了MultiMap.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MultiMap.get()
方法的具体详情如下:
包路径:org.vertx.java.core.MultiMap
类名称:MultiMap
方法名:get
暂无
代码示例来源:origin: org.commonjava.vertx/vabr-api
public String get( final String name )
{
return map.get( name );
}
代码示例来源:origin: de.leanovate.router/router-base
@Override
public Optional<String> getQueryParam(final String name) {
return Optional.ofNullable(request.params().get(name));
}
代码示例来源:origin: io.fabric8/gateway-apiman
/**
* Gets the API Key from the request. The API key can be passed either via
* a custom http request header called X-API-Key or else by a query parameter
* in the URL called apikey.
* @param request the inbound request
* @return the api key or null if not found
*/
protected String getApiKey(HttpServerRequest request) {
String apiKey = request.headers().get("X-API-Key"); //$NON-NLS-1$
if (apiKey == null || apiKey.trim().length() == 0) {
apiKey = getApiKeyFromQuery(request);
}
return apiKey;
}
代码示例来源:origin: etsy/statsd-jvm-profiler
@Override
public void handle(HttpServerRequest httpServerRequest) {
String profilerToDisable = httpServerRequest.params().get("profiler");
ScheduledFuture<?> future = activeProfilers.get(profilerToDisable);
future.cancel(false);
httpServerRequest.response().end(String.format("Disabled profiler %s", profilerToDisable));
}
};
代码示例来源:origin: vert-x/mod-lang-php
@Override
public Value offsetGet(Value name) {
return Env.getCurrent().wrapJava(map.get(name.toString()));
}
代码示例来源:origin: com.github.flowersinthesand/portal-vertx
void openHttp(HttpServerRequest req) {
String when = req.params().get("when");
String id = req.params().get("id");
String transport = req.params().get("transport");
if (transport.equals("sse") || transport.startsWith("stream")) {
StreamSocket socket = new StreamSocket(req);
sockets.put(id, socket);
socket.onOpen();
} else if (transport.startsWith("longpoll")) {
if (when.equals("open")) {
LongPollSocket socket = new LongPollSocket(req);
sockets.put(id, socket);
socket.onOpen();
} else if (when.equals("poll")) {
((LongPollSocket) sockets.get(id)).refresh(req, false);
}
}
}
代码示例来源:origin: org.commonjava.vertx/vabr-api
public static String requestUri( final HttpServerRequest request )
{
final String hostHeader = request.headers()
.get( "Host" );
String hostAndPort = request.absoluteURI()
.getHost();
final int port = request.absoluteURI()
.getPort();
if ( port != 80 && port != 443 )
{
hostAndPort += ":" + port;
}
final String uri = request.absoluteURI()
.toString();
final int idx = uri.indexOf( hostAndPort );
final StringBuilder sb = new StringBuilder();
sb.append( uri.substring( 0, idx ) );
sb.append( hostHeader );
sb.append( uri.substring( idx + hostAndPort.length() ) );
return sb.toString();
}
代码示例来源:origin: etsy/statsd-jvm-profiler
@Override
public void handle(HttpServerRequest httpServerRequest) {
String profilerName = httpServerRequest.params().get("profiler");
Profiler profiler = activeProfilers.get(profilerName);
httpServerRequest.response().end(String.format("Recorded stats %d\n", profiler.getRecordedStats()));
}
};
代码示例来源:origin: com.github.flowersinthesand/portal-vertx
@Override
public void handle(HttpServerRequest req) {
req.response().headers().add(AbstractSocketFactory.noCacheHeader()).add(AbstractSocketFactory.corsHeader(req.headers().get("Origin")));
String when = req.params().get("when");
if (when.equals("open") || when.equals("poll")) {
socketFactory.openHttp(req);
} else if (when.equals("abort")) {
socketFactory.abort(req.params().get("id"));
}
}
};
代码示例来源:origin: io.vertx/vertx-platform
protected void handleRedirect(HttpClientResponse resp) {
// follow redirects
String location = resp.headers().get("location");
if (location == null) {
log.error("HTTP redirect with no location header");
} else {
URI redirectURI;
try {
redirectURI = new URI(location);
client.close();
client = null;
int redirectPort = redirectURI.getPort();
if (redirectPort == -1) {
redirectPort = 80;
}
// Use raw values from location header
String uri = redirectURI.getRawPath();
String query = redirectURI.getRawQuery();
if (query != null) {
uri = uri + "?" + query; // Include query in URL
}
createClient(redirectURI.getScheme(), redirectURI.getHost(), redirectPort);
makeRequest(redirectURI.getScheme(), redirectURI.getHost(), redirectPort, uri);
} catch (URISyntaxException e) {
log.error("Invalid redirect URI: " + location);
}
}
}
代码示例来源:origin: org.commonjava.aprox/aprox-subsys-vertx
public static String getStandardAccept( final HttpServerRequest request, final String defaultAccept )
{
String accept = request.headers()
.get( RouteHeader.base_accept.header() );
logger.info( "Got base-accept ({}): {}", RouteHeader.base_accept.header(), accept );
if ( accept == null )
{
accept = request.headers()
.get( RouteHeader.accept.header() );
logger.info( "Got raw-accept ({}): {}", RouteHeader.accept.header(), accept );
}
if ( accept != null )
{
accept = ApplicationContent.getStandardAccept( accept );
}
if ( accept == null )
{
logger.info( "Using default accept: {}", defaultAccept );
accept = defaultAccept;
}
return accept;
}
代码示例来源:origin: io.vertx/mod-rxvertx
/** Validate response */
public static void checkResponse(HttpClientResponse httpResp) throws RuntimeException {
// Must use Rx methods to access stream as Observable
assert(httpResp instanceof RxHttpClientResponse);
if (httpResp.statusCode()>=400)
throw new RuntimeException("HTTP request failed (code="+httpResp.statusCode()+",msg="+httpResp.statusMessage()+")");
else if (httpResp.statusCode()>=300)
throw new RuntimeException("HTTP redirect not supported (code="+httpResp.statusCode()+",msg="+httpResp.statusMessage()+",location="+httpResp.headers().get("Location")+")");
}
}
代码示例来源:origin: RichardHightower/slumberdb
private void handleRestGET(HttpServerRequest request) {
String ipAddress = request.remoteAddress().toString();
dataStoreServer.handleCallWithMap(ipAddress, toMap(request.params()), request.uri(), request.response());
if (request.params().get(ProtocolConstants.ACTION_MAP_KEY).startsWith(ProtocolConstants.SET_VERB)) {
request.response().end("[\"ok\"]");
}
}
代码示例来源:origin: boonproject/boon
public static boolean setAllowOriginHeaders(HttpServerRequest request) {
String origin = request.headers().get("Origin");
if (origin != null) {
request.response().putHeader("Access-Control-Allow-Origin", origin);
request.response().putHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
request.response().putHeader("Access-Control-Allow-Headers", "Content-Type");
return true;
}
return false;
}
}
代码示例来源:origin: org.commonjava.aprox/aprox-subsys-vertx
@FilterRoute( path = "/(?!.*(login|logout)).*", method = Method.ANY )
public void setUser( final HttpServerRequest request, final ExecutionChain chain )
throws Exception
{
// FIXME: Need a proper login!
String user = request.headers()
.get( ApplicationHeader.x_forwarded_for.key() );
if ( user == null )
{
user = request.remoteAddress()
.getHostString();
}
request.params()
.add( SecurityParam.user.key(), user );
chain.handle();
}
代码示例来源:origin: com.github.flowersinthesand/portal-vertx
public StreamSocket(HttpServerRequest req) {
this.res = req.response();
this.params = new LinkedHashMap<>();
for (Entry<String, String> entry : req.params()) {
this.params.put(entry.getKey(), entry.getValue());
}
this.isAndroid = isAndroid(req.headers().get("user-agent"));
res.exceptionHandler(new Handler<Throwable>() {
@Override
public void handle(Throwable event) {
onClose();
}
});
res.closeHandler(new VoidHandler() {
@Override
protected void handle() {
onClose();
}
});
res.setChunked(true).putHeader("content-type", streamContentType() + "; charset=utf-8");
res.write(padding2K);
if (isAndroid) {
res.write(padding2K);
}
res.write("\n");
}
代码示例来源:origin: org.commonjava.aprox/aprox-subsys-vertx
@Route( "/whoami" )
public void whoami( final HttpServerRequest request )
{
Respond.to( request )
.ok()
.entity( request.params()
.get( SecurityParam.user.key() ) )
.send();
}
代码示例来源:origin: com.github.flowersinthesand/portal-vertx
@Override
public void handle(HttpServerRequest req) {
req.response().headers().add(AbstractSocketFactory.noCacheHeader()).add(AbstractSocketFactory.corsHeader(req.headers().get("Origin")));
req.bodyHandler(new Handler<Buffer>() {
@Override
public void handle(Buffer body) {
socketFactory.fire(body.toString().substring("data=".length()));
};
});
req.response().end();
}
};
代码示例来源:origin: com.github.flowersinthesand/portal-vertx
private void refresh(HttpServerRequest req, final boolean open) {
res = req.response();
res.exceptionHandler(new Handler<Throwable>() {
@Override
public void handle(Throwable event) {
onClose();
}
});
res.closeHandler(new VoidHandler() {
@Override
protected void handle() {
if (!open && res != null) {
onClose();
}
}
});
res.putHeader("content-type", longpollContentType() + "; charset=utf-8");
if (open) {
res.end();
res.close();
} else {
retrieveCache(req.params().get("lastEventIds"));
}
}
代码示例来源:origin: org.commonjava.aprox/aprox-subsys-vertx
public static HttpServerResponse formatCreatedResponse( final HttpServerRequest request,
final UriFormatter uriFormatter, final String... params )
{
final String baseUri = request.params()
.get( _classContextUrl.key() );
final String location = uriFormatter.formatAbsolutePathTo( baseUri, params );
request.resume()
.response()
.putHeader( ApplicationHeader.location.key(), location )
.setStatusCode( ApplicationStatus.CREATED.code() )
.setStatusMessage( ApplicationStatus.CREATED.message() );
return request.response();
}
内容来源于网络,如有侵权,请联系作者删除!