org.jooby.Env.router()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(127)

本文整理了Java中org.jooby.Env.router()方法的一些代码示例,展示了Env.router()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Env.router()方法的具体详情如下:
包路径:org.jooby.Env
类名称:Env
方法名:router

Env.router介绍

[英]Application router.
[中]应用路由器。

代码示例

代码示例来源:origin: jooby-project/jooby

@Override
public void configure(final Env env, final Config conf, final Binder binder) {
 String baseurl = this.baseurl.orElseGet(() -> {
  if (conf.hasPath(SITEMAP_BASEURL)) {
   return conf.getString(SITEMAP_BASEURL);
  } else {
   Config $ = conf.getConfig("application");
   return "http://" + $.getString("host") + ":" + $.getString("port") + $.getString("path");
  }
 });
 wpp.accept(binder);
 env.router().get(path, new SitemapHandler(path, NOT_ME.and(filter), gen(baseurl)));
}

代码示例来源:origin: jooby-project/jooby

@Override
public void configure(final Env env, final Config conf, final Binder binder) {
 boolean whoops = conf.hasPath("whoops.enabled")
   ? conf.getBoolean("whoops.enabled")
   : "dev".equals(env.name());
 if (whoops) {
  ClassLoader loader = env.router().getClass().getClassLoader();
  Handler handler = prettyPage(loader, SourceLocator.local(), maxFrameSize, log);
  env.router().err(tryPage(handler, log));
 }
}

代码示例来源:origin: jooby-project/jooby

@Override
public void configure(final Env env, final Config conf, final Binder binder) {
 env.router()
  .map(reactor(flux, mono));
}

代码示例来源:origin: jooby-project/jooby

@Override public void configure(final Env env, final Config conf, final Binder binder)
  throws Exception {
 boolean useFile = Stream.of(swaggerOptions, ramlOptions)
   .filter(Objects::nonNull)
   .filter(it -> it.file != null)
   .findFirst()
   .isPresent();
 Throwing.Function<Set<Route.Definition>, List<RouteMethod>> provider = null;
 if (!useFile) {
  Path dir = Optional.ofNullable(basedir).orElse(Paths.get(conf.getString("user.dir")));
  ApiParser parser = new ApiParser(dir, filter);
  customizer.forEach(parser::modify);
  provider = routes -> parser
    .parseFully(conf.getString("application.class"), new ArrayList<>(routes));
  if (!env.name().equals("dev")) {
   provider = provider.memoized();
  }
  binder.bind(ApiParser.class).toInstance(parser);
 }
 String contextPath = conf.getString("application.path");
 if (swaggerOptions != null) {
  swagger(contextPath, env.router(), swaggerOptions, conf, swagger, provider);
 }
 if (ramlOptions != null) {
  raml(contextPath, env.router(), ramlOptions, raml, provider);
 }
}

代码示例来源:origin: jooby-project/jooby

@Override
public void configure(final Env env, final Config conf, final Binder binder) {
 // empty metric & checks
 MapBinder.newMapBinder(binder, String.class, Metric.class);
 MapBinder.newMapBinder(binder, String.class, HealthCheck.class);
 Router routes = env.router();
 MetricHandler mhandler = new MetricHandler();
 routes.use("GET", this.pattern + "/metrics", mhandler);
 routes.use("GET", this.pattern + "/metrics/:type", mhandler);
 routes.use("GET", this.pattern + "/healthcheck", new HealthCheckHandler());
 Multibinder<Reporter> reporters = Multibinder.newSetBinder(binder, Reporter.class);
 binder.bind(MetricRegistry.class).toInstance(metricRegistry);
 this.reporters.forEach(it -> reporters.addBinding().toInstance(it.apply(metricRegistry, conf)));
 binder.bind(MetricRegistryInitializer.class).asEagerSingleton();
 env.onStop(app -> app.require(MetricRegistryInitializer.class).close());
 binder.bind(HealthCheckRegistry.class).toInstance(healthCheckRegistry);
 binder.bind(HealthCheckRegistryInitializer.class).asEagerSingleton();
 bindings.forEach(it -> it.bind(binder, routes, conf));
 this.routes.forEach(it -> it.accept(routes));
}

代码示例来源:origin: jooby-project/jooby

@Override
public void configure(final Env env, final Config conf, final Binder binder) {
 Config $cookie = conf.getConfig("flash.cookie");
 String cpath = $cookie.getString("path");
 boolean chttp = $cookie.getBoolean("httpOnly");
 boolean csecure = $cookie.getBoolean("secure");
 Cookie.Definition cookie = this.cookie
   .orElseGet(() -> new Cookie.Definition($cookie.getString("name")));
 // uses user provided or fallback to defaults
 cookie.path(cookie.path().orElse(cpath))
   .httpOnly(cookie.httpOnly().orElse(chttp))
   .secure(cookie.secure().orElse(csecure));
 env.router()
   .use(method, path, new FlashScopeHandler(cookie, decoder, encoder))
   .name("flash-scope");
}

代码示例来源:origin: jooby-project/jooby

@Override
public void configure(final Env env, final Config conf, final Binder binder) {
 // dump rx.* as system properties
 conf.getConfig("rx")
  .withoutPath("schedulers").entrySet()
  .forEach(
   e -> System.setProperty("rx." + e.getKey(), e.getValue().unwrapped().toString()));
 Map<String, Executor> executors = new HashMap<>();
 super.configure(env, conf, binder, executors::put);
 env.router()
  .map(rx(observable, single, completable));
 /**
  * Side effects of global/evil static state. Hack to turn off some of this errors.
  */
 trySchedulerHook(executors);
 // shutdown schedulers: silent shutdown in dev mode between app reloads
 env.onStop(() -> {
  try {
   Schedulers.shutdown();
  } catch (Throwable ex) {
   log.debug("Schedulers.shutdown() resulted in error", ex);
  }
 });
}

代码示例来源:origin: jooby-project/jooby

});
env.router()
  .use(it.method(), it.pattern(), new OpenHandle(jdbi, it))
  .name("transactionPerRequest");

代码示例来源:origin: jooby-project/jooby

.whitelistPackages(spec.toArray(new String[spec.size()]));
Router routes = env.router();

代码示例来源:origin: jooby-project/jooby

.setDefault().toInstance(new DefaultClientFinder());
Router routes = env.router();

代码示例来源:origin: jooby-project/jooby

env.router().get(checkConfig.getString("path"), () -> response);

代码示例来源:origin: jooby-project/jooby

env.router()
  .map(mapper());

代码示例来源:origin: jooby-project/jooby

Router router = env.router();

代码示例来源:origin: jooby-project/jooby

AssetCompiler compiler = new AssetCompiler(assetClassLoader, conf);
Router routes = env.router();
List<String> dist = dev ? ImmutableList.of("dev") : ImmutableList.of(envname, "dist");
String prefix = dist.stream()

代码示例来源:origin: jooby-project/jooby

: "dev".equals(env.name());
if (enabled) {
 Router router = env.router();

代码示例来源:origin: jooby-project/jooby

static void install(final Env env, final Config conf) {
 String path = conf.getString("crash.httpshell.path");
 Router router = env.router();
 router.get(path + "/{cmd:.*}", router.promise("direct", (req, deferred) -> {
  MediaType type = req.accepts(MediaType.json)
    .map(it -> MediaType.json)
    .orElse(MediaType.html);
  PluginContext ctx = req.require(PluginContext.class);
  ShellFactory shellFactory = ctx.getPlugin(ShellFactory.class);
  Shell shell = shellFactory.create(null);
  String cmd = req.param("cmd").value().replaceAll("/", " ");
  ShellProcess process = shell.createProcess(cmd);
  ShellProcessContext spc = new SimpleProcessContext(
    result -> deferred.resolve(result.type(type)));
  process.execute(spc);
 }));
}

代码示例来源:origin: jooby-project/jooby

static void install(final Env env, final Config conf) {
 Router routes = env.router();
 String path = conf.getString("crash.webshell.path");
 String title = conf.getString("application.name") + " shell";

代码示例来源:origin: jooby-project/jooby

});
env.router()
  .map(new CassandraMapper());

代码示例来源:origin: org.jooby/jooby-whoops

@Override
public void configure(final Env env, final Config conf, final Binder binder) {
 boolean whoops = conf.hasPath("whoops.enabled")
   ? conf.getBoolean("whoops.enabled")
   : "dev".equals(env.name());
 if (whoops) {
  ClassLoader loader = env.router().getClass().getClassLoader();
  Handler handler = prettyPage(loader, SourceLocator.local(), maxFrameSize, log);
  env.router().err(tryPage(handler, log));
 }
}

代码示例来源:origin: org.jooby/jooby-reactor

@Override
public void configure(final Env env, final Config conf, final Binder binder) {
 env.router()
  .map(reactor(flux, mono));
}

相关文章