module web_base
import model::model_views
+import model::model_json
import nitcorn
-import json
# Nitcorn server runned by `nitweb`.
#
# Render a view as a HttpResponse 200.
fun render_view(view: NitView): HttpResponse do
var response = new HttpResponse(200)
- response.body = view.render(srv).write_to_string
+ response.body = view.render.write_to_string
return response
end
# Model to use.
var model: Model
+ # Find the MEntity ` with `full_name`.
+ fun find_mentity(model: ModelView, full_name: nullable String): nullable MEntity do
+ if full_name == null then return null
+ return model.mentity_by_full_name(full_name.from_percent_encoding)
+ end
+
# Init the model view from the `req` uri parameters.
fun init_model_view(req: HttpRequest): ModelView do
var view = new ModelView(model)
-
var show_private = req.bool_arg("private") or else false
if not show_private then view.min_visibility = protected_visibility
# A NitView is rendered by an action.
interface NitView
# Renders this view and returns something that can be written to a HTTP response.
- fun render(srv: NitServer): Writable is abstract
+ fun render: Writable is abstract
end
redef class HttpRequest