本文整理匯總了Java中netflix.karyon.transport.http.SimpleUriRouter類的典型用法代碼示例。如果您正苦於以下問題:Java SimpleUriRouter類的具體用法?Java SimpleUriRouter怎麽用?Java SimpleUriRouter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SimpleUriRouter類屬於netflix.karyon.transport.http包,在下文中一共展示了SimpleUriRouter類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: TriathlonRouter
import netflix.karyon.transport.http.SimpleUriRouter; //導入依賴的package包/類
public TriathlonRouter(HealthCheckEndpoint healthCheckEndpoint, TriathlonEndpointImpl triathlonEndpoint) {
delegate = new SimpleUriRouter<>();
delegate.addUri("/healthcheck", healthCheckEndpoint)
.addUri("/v2/apps",
(request, response) -> {
Observable<Void> result = Observable.defer(response::close);
if (request.getHttpMethod() == HttpMethod.POST) {
result = triathlonEndpoint.postApps(request, response);
}
return result;
});
}
示例2: IndexResource
import netflix.karyon.transport.http.SimpleUriRouter; //導入依賴的package包/類
public IndexResource() {
endpoint = new HelloEndpoint();
delegate = new SimpleUriRouter<>();
delegate
.addUri("/", new RequestHandler<ByteBuf, ByteBuf>() {
@Override
public Observable<Void> handle(HttpServerRequest<ByteBuf> request,
final HttpServerResponse<ByteBuf> response) {
return endpoint.getHello()
.flatMap(new Func1<String, Observable<Void>>() {
@Override
public Observable<Void> call(String body) {
String instanceId = "";
String userdata = "";
try{
instanceId = execCmd("curl http://metadata/computeMetadata/v1/instance/id -H Metadata-Flavor:Google") + execCmd("wget -q -O - http://instance-data/latest/meta-data/instance-id");
userdata = System.getenv("USERDATA");
} catch (Exception e){
e.printStackTrace();
}
response.writeString("<html><head><style>body{text-align:center;font-family:'Lucida Grande'}</style></head><body><img src='http://kenzan.com/wp-content/themes/kenzan/images/logo-reg.png' /><h2>Example Spinnaker Application</h2><h3>Instance Id " + instanceId + "</h3><h3>$USERDATA ENV VAR: " + userdata + "</h3></body></html>");
return response.close();
}
});
}
});
}
示例3: ExampleRouter
import netflix.karyon.transport.http.SimpleUriRouter; //導入依賴的package包/類
public ExampleRouter() {
delegate = new SimpleUriRouter<>();
HealthCheck healthCheckHandler = new HealthCheck();
delegate
.addUri("", new IndexResource())
.addUri("/hello/*", new HelloResource())
.addUri("/healthcheck", new HealthCheckEndpoint(healthCheckHandler));
}