-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathserver.lua
30 lines (21 loc) · 1 KB
/
server.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
local pathJoin = require('luvi').path.join
local static = require('weblit-static')
local blog = require('controllers/blog')
local env = require('env')
require('weblit-app')
.bind({host = "0.0.0.0", port = env.get("PORT") or 8080})
-- Configure weblit server
.use(require('weblit-logger'))
.use(require('weblit-auto-headers'))
.route({ method = "GET", path = "/snapshots"}, require('snapshots'))
.route({ method = "GET", path = "/stats"}, require('stats'))
-- Serve non-blog content pages
.route({ method = "GET", path = "/" }, require('controllers/page'))
.route({ method = "GET", path = "/:name.html" }, require('controllers/page'))
-- Serve blog articles
.route({ method = "GET", path = "/blog/"}, blog.index)
.route({ method = "GET", path = "/blog/tags/:tag"}, blog.tags)
.route({ method = "GET", path = "/blog/:name.html" }, blog.article)
.route({ method = "GET", path = "/blog/:path:"}, static(pathJoin(module.dir, "articles")))
.use(static(pathJoin(module.dir, "static")))
.start()