diff --git a/example/Index.re b/example/Index.re index 1ace726..8729845 100644 --- a/example/Index.re +++ b/example/Index.re @@ -57,6 +57,10 @@ let makeSuccessJson = () => { }; let app = express(); +/* + If you would like to set view engine + App.set(app, "view engine", "pug"); + */ App.disable(app, ~name="x-powered-by"); @@ -165,6 +169,14 @@ App.deleteWithMany( |], ); +/* If you have setted up view engine then you can uncomment that "get" +App.get(app, ~path="/render") @@ +Middleware.from((_, _) => { + let dict: Js.Dict.t(string) = Js.Dict.empty(); + Response.render("index", dict, ()); +}); +*/ + App.get(app, ~path="/baseUrl") @@ Middleware.from((next, req) => switch (Request.baseUrl(req)) { diff --git a/src/Express.re b/src/Express.re index 7a3a2b2..52980f8 100644 --- a/src/Express.re +++ b/src/Express.re @@ -369,6 +369,7 @@ module Response = { [@bs.send.pipe: t] external setType : (string) => t = "type"; [@bs.send.pipe: t] external setLinks : Js.Dict.t(string) => t = "links"; [@bs.send.pipe: t] external end_ : complete = "end"; + [@bs.send.pipe: t] external render: (string, Js.Dict.t(string), 'a) => complete = "render"; }; module Next: { @@ -695,6 +696,7 @@ module App = { let listen = (app, ~port=3000, ~hostname="0.0.0.0", ~onListen=(_) => (), ()) => listen_(app, port, hostname, onListen); [@bs.send] external disable: (t, ~name: string) => unit = ""; + [@bs.send] external set: (t, string, string) => unit = "set"; }; let express = App.make; diff --git a/src/Express.rei b/src/Express.rei index 7e544b5..4838cc2 100644 --- a/src/Express.rei +++ b/src/Express.rei @@ -247,6 +247,7 @@ module Response: { let setType: (string, t) => t; let setLinks: (Js.Dict.t(string), t) => t; let end_: t => complete; + let render: (string, Js.Dict.t(string), 'a, t) => complete; }; module Next: { @@ -389,6 +390,7 @@ module App: { ) => HttpServer.t; let disable: (t, ~name: string) => unit; + let set: (t, string, string) => unit; };