staticFileLocation("/public"); initExceptionHandler((e) -> HABridge.theExceptionHandler(e, bridgeSettings.getBridgeSettingsDescriptor().getServerPort())); if(!bridgeSettings.getBridgeControl().isReinit())
public WebConfig(MiniTwitService service) { this.service = service; staticFileLocation("/public"); setupRoutes(); }
/** * Start the server. */ public void start() { if(running.compareAndSet(false, true)) { Spark.setPort(port); Spark.staticFileLocation(staticFileLocation); // Register all the EndpointContainers and listen for any requests Reflections reflections = new Reflections( "com.cinchapi.concourse.server.http.router"); Set<EndpointContainer> weighted = Sets.newTreeSet(); for (Class<? extends EndpointContainer> container : reflections .getSubTypesOf(EndpointContainer.class)) { EndpointContainer instance = Reflection.newInstance(container, concourse); weighted.add(instance); } for (EndpointContainer instance : weighted) { initialize(instance); } Logger.info("HTTP Server enabled on port {}", port); } }
/** * Creates a controller that maps requests to actions. */ public UserController(final UserService userService) { Spark.staticFileLocation("/public"); get("/api/users", (req, res) -> userService.getAllUsers(), json()); get("/api/users/:id", (req, res) -> userService.getUser(req.params(":id")), json()); post("/api/users", (req, res) -> userService.createUser(req.queryParams("name"), req.queryParams("email")), json()); put("/api/users/:id", (req, res) -> userService.updateUser( req.params(":id"), req.queryParams("name"), req.queryParams("email") ), json()); delete("/api/users/:id", (req, res) -> userService.deleteUser(req.params(":id")), json()); after((req, res) -> { res.type("application/json"); }); exception(IllegalArgumentException.class, (error, req, res) -> { res.status(400); res.body(toJson(new ResponseError(error))); }); }
/** * 启动服务器 */ private void startServer() { CountInfo countInfo = StatTool.count(); //设置端口 if (System.getenv("PORT") != null) { port(Integer.valueOf(System.getenv("PORT"))); } //web staticFileLocation("/public"); //index page get("/", (request, response) -> { Map<String, Object> model = new HashMap<String, Object>(); model.put("stat", countInfo); // The vm files are located under the resources directory return new ModelAndView(model, "public/html/index.vm"); }, new VelocityTemplateEngine()); //search action post("/search", (request, response) -> search(request.queryParams("keyword")), new JsonTransformer()); gankHub = new GankHub(); gankHub.startService(); logger.info("server started"); }
public static void main(String... args) { staticFileLocation("/static");
public void start() { Spark.ipAddress(config.bindHost()); Spark.port(config.bindPort()); Spark.threadPool(config.threadNum()); Spark.staticFileLocation("/static"); if (!config.readonly()) { this.initWritableHandlers(); } this.initReadonlyHandlers(); this.initViewHandlers(); this.initExceptionHandlers(); Spark.awaitInitialization(); LOG.warn("captain server started"); }
private static void start() { staticFileLocation("/public"); webSocket("/socket/*", TestLiveWebsocket.class); ipAddress(Configuration.getInstance().getIp());