diff options
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -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) |
