summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/main.go b/main.go
index 09ebd01..00629f3 100644
--- a/main.go
+++ b/main.go
@@ -90,6 +90,27 @@ func main() {
)
return 0
}
+ routeModule["static"] = func (l *Lua) int {
+ var route, dir string
+ err := l.Scan(&route, &dir)
+ if err != nil {
+ fmt.Println("error:", err)
+ // FIXME: handle
+ return 0
+ }
+ // check if route is already registered. otherwise
+ // mux.HandleFunc will panic
+ _, ok := routes[route]
+ if ok {
+ return 0
+ }
+ routes[route] = true
+ mux.Handle(
+ route,
+ http.StripPrefix("/static/", http.FileServer(http.Dir(dir))),
+ )
+ return 0
+ }
// define luna.http module
httpModule := make(map[string]any)