use of io.servicetalk.http.router.jersey.HttpJerseyRouterBuilder in project baremaps by baremaps.
the class Studio method call.
@Override
public Integer call() throws Exception {
// Configure serialization
ObjectMapper mapper = defaultObjectMapper();
// Configure jdbi and set the ObjectMapper
DataSource datasource = PostgresUtils.datasource(this.database);
Jdbi jdbi = Jdbi.create(datasource).installPlugin(new PostgresPlugin()).installPlugin(new Jackson2Plugin()).configure(Jackson2Config.class, config -> config.setMapper(mapper));
// Initialize the application
ResourceConfig application = new ResourceConfig().registerClasses(SwaggerResource.class, RootResource.class, CorsFilter.class, ConformanceResource.class, CollectionsResource.class, StylesResource.class, TilesetsResource.class, StudioResource.class, ImportResource.class, MultiPartFeature.class).register(new ApiResource("studio-openapi.yaml")).register(contextResolverFor(mapper)).register(new AbstractBinder() {
@Override
protected void configure() {
bind(datasource).to(DataSource.class);
bind(jdbi).to(Jdbi.class);
}
});
BlockingStreamingHttpService httpService = new HttpJerseyRouterBuilder().buildBlockingStreaming(application);
ServerContext serverContext = HttpServers.forPort(port).listenBlockingStreamingAndAwait(httpService);
logger.info("Listening on {}", serverContext.listenAddress());
serverContext.awaitShutdown();
return 0;
}
use of io.servicetalk.http.router.jersey.HttpJerseyRouterBuilder in project baremaps by baremaps.
the class View method call.
@Override
public Integer call() throws Exception {
ObjectMapper objectMapper = defaultObjectMapper();
BlobStore blobStore = options.blobStore();
TileJSON tileJSON = objectMapper.readValue(blobStore.get(this.tileset).getInputStream(), TileJSON.class);
CaffeineSpec caffeineSpec = CaffeineSpec.parse(cache);
DataSource datasource = PostgresUtils.datasource(database);
List<PostgresQuery> queries = asPostgresQuery(tileJSON);
TileStore tileStore = new PostgresTileStore(datasource, queries);
TileStore tileCache = new TileCache(tileStore, caffeineSpec);
// Configure the application
ResourceConfig application = new ResourceConfig().register(CorsFilter.class).register(ViewerResources.class).register(contextResolverFor(objectMapper)).register(new AbstractBinder() {
@Override
protected void configure() {
bind(tileset).to(URI.class).named("tileset");
bind(style).to(URI.class).named("style");
bind(blobStore).to(BlobStore.class);
bind(tileCache).to(TileStore.class);
}
});
BlockingStreamingHttpService httpService = new HttpJerseyRouterBuilder().buildBlockingStreaming(application);
ServerContext serverContext = HttpServers.forPort(port).listenBlockingStreamingAndAwait(httpService);
logger.info("Listening on {}", serverContext.listenAddress());
serverContext.awaitShutdown();
return 0;
}
use of io.servicetalk.http.router.jersey.HttpJerseyRouterBuilder in project servicetalk by apple.
the class AbstractBasicAuthSecurityContextFilterTest method setUp.
void setUp(final boolean withUserInfo) throws Exception {
final Builder<BasicUserInfo> builder = new Builder<>(CREDENTIALS_VERIFIER, "test-realm");
if (withUserInfo) {
builder.userInfoAsyncContextKey(TEST_USER_INFO_AC_KEY);
}
serverContext = HttpServers.forAddress(localAddress(0)).appendServiceFilter(builder.buildServer()).listenStreamingAndAwait(new HttpJerseyRouterBuilder().buildStreaming(application(withUserInfo ? TEST_USER_INFO_AC_KEY : null)));
httpClient = HttpClients.forSingleAddress(serverHostAndPort(serverContext)).buildBlocking();
}
use of io.servicetalk.http.router.jersey.HttpJerseyRouterBuilder in project servicetalk by apple.
the class HelloWorldJaxRsServer method main.
/**
* Starts this server.
*
* @param args Program arguments, none supported yet.
* @throws Exception If the server could not be started.
*/
public static void main(String[] args) throws Exception {
// Create configurable starter for HTTP server.
ServerContext serverContext = HttpServers.forPort(8080).listenStreamingAndAwait(new HttpJerseyRouterBuilder().buildStreaming(new HelloWorldJaxRsApplication()));
LOGGER.info("Listening on {}", serverContext.listenAddress());
// Blocks and awaits shutdown of the server this ServerContext represents.
serverContext.awaitShutdown();
}
use of io.servicetalk.http.router.jersey.HttpJerseyRouterBuilder in project baremaps by baremaps.
the class Edit method call.
@Override
public Integer call() throws Exception {
BlobStore blobStore = options.blobStore();
DataSource dataSource = PostgresUtils.datasource(database);
// Configure serialization
ObjectMapper objectMapper = defaultObjectMapper();
// Configure the application
ResourceConfig application = new ResourceConfig().register(CorsFilter.class).register(EditorResources.class).register(contextResolverFor(objectMapper)).register(new AbstractBinder() {
@Override
protected void configure() {
bind(tileset).to(URI.class).named("tileset");
bind(style).to(URI.class).named("style");
bind(blobStore).to(BlobStore.class);
bind(dataSource).to(DataSource.class);
bind(objectMapper).to(ObjectMapper.class);
}
});
BlockingStreamingHttpService httpService = new HttpJerseyRouterBuilder().buildBlockingStreaming(application);
ServerContext serverContext = HttpServers.forPort(port).listenBlockingStreamingAndAwait(httpService);
logger.info("Listening on {}", serverContext.listenAddress());
serverContext.awaitShutdown();
return 0;
}
Aggregations