Valatra 是一个 Vala 语言用来开发 Web 应用的框架,灵感来自于 Ruby 的 Sinatra 框架。
示例代码:
var app = new Valatra.App(); app.port = 3333; app.get('/', (req, res) => { /* 200 by default */ res.status = 200; /* sets content-type, 'text/html' by default */ res.type("text/plain"); /* set whatever HTTP header */ res.headers["MY_HEADER"] = "Hello!"; res.setBody("Hello World!"); }); // this would be called for a request to '/user/john', or '/user/123', etc app.get("/user/:id", (req, res) => { var id = req.params["id"]; // do something with id... }); app.post("/submit", (req, res) => { // if a POST was made to "/submit with a body of //"title=My+Awesome+Title", req.params["title"] // would return that req.params["title"]; }); app.start();