- var model = mainmodule.model
- var modelbuilder = toolcontext.modelbuilder
-
- # Run the server
- var host = toolcontext.opt_host.value or else "localhost"
- var port = toolcontext.opt_port.value
-
- var srv = new NitServer(host, port.to_i)
- srv.routes.add new Route("/random", new RandomAction(srv, model))
- srv.routes.add new Route("/doc/:namespace", new DocAction(srv, model, modelbuilder))
- srv.routes.add new Route("/code/:namespace", new CodeAction(srv, model, modelbuilder))
- srv.routes.add new Route("/search/:namespace", new SearchAction(srv, model))
- srv.routes.add new Route("/uml/:namespace", new UMLDiagramAction(srv, model, mainmodule))
- srv.routes.add new Route("/", new TreeAction(srv, model))
-
- srv.listen
+ var config = build_config(toolcontext, mainmodule)
+ config.model.nitdoc_md_processor = config.md_processor
+ config.build_catalog
+
+ var app = new App
+
+ app.use_before("/*", new SessionInit)
+ app.use_before("/*", new RequestClock)
+ app.use("/api", new APIRouter(config))
+ app.use("/login", new GithubLogin(config.github_client_id))
+ app.use("/oauth", new GithubOAuthCallBack(config.github_client_id, config.github_client_secret))
+ app.use("/logout", new GithubLogout)
+ app.use("/*", new StaticHandler(toolcontext.share_dir / "nitweb", "index.html"))
+ app.use_after("/*", new ConsoleLog)
+
+ app.listen(config.app_host, config.app_port)