nitweb: move APIRouter to nitweb.nit
authorAlexandre Terrasa <alexandre@moz-code.org>
Mon, 6 Jun 2016 11:46:41 +0000 (07:46 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Mon, 6 Jun 2016 11:46:41 +0000 (07:46 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/nitweb.nit
src/web/model_api.nit

index 93d15aa..452179f 100644 (file)
@@ -57,6 +57,32 @@ private class NitwebPhase
        end
 end
 
+# Group all api handlers in one router.
+class APIRouter
+       super Router
+
+       # Model to pass to handlers.
+       var model: Model
+
+       # ModelBuilder to pass to handlers.
+       var modelbuilder: ModelBuilder
+
+       # Mainmodule to pass to handlers.
+       var mainmodule: MModule
+
+       # Catalog to pass to handlers.
+       var catalog: Catalog
+
+       init do
+               use("/list", new APIList(model, mainmodule))
+               use("/search", new APISearch(model, mainmodule))
+               use("/random", new APIRandom(model, mainmodule))
+               use("/entity/:id", new APIEntity(model, mainmodule))
+               use("/code/:id", new APIEntityCode(model, mainmodule, modelbuilder))
+               use("/uml/:id", new APIEntityUML(model, mainmodule))
+       end
+end
+
 # build toolcontext
 var toolcontext = new ToolContext
 var tpl = new Template
index ba01837..080dcb2 100644 (file)
@@ -18,29 +18,6 @@ import web_base
 import highlight
 import uml
 
-# Group all api handlers in one router.
-class APIRouter
-       super Router
-
-       # Model to pass to handlers.
-       var model: Model
-
-       # ModelBuilder to pass to handlers.
-       var modelbuilder: ModelBuilder
-
-       # Mainmodule to pass to handlers.
-       var mainmodule: MModule
-
-       init do
-               use("/list", new APIList(model, mainmodule))
-               use("/search", new APISearch(model, mainmodule))
-               use("/random", new APIRandom(model, mainmodule))
-               use("/entity/:id", new APIEntity(model, mainmodule))
-               use("/code/:id", new APIEntityCode(model, mainmodule, modelbuilder))
-               use("/uml/:id", new APIEntityUML(model, mainmodule))
-       end
-end
-
 # List all mentities.
 #
 # MEntities can be filtered on their kind using the `k` parameter.