rsslair/router.go

33 lines
713 B
Go

package main
import (
"net/http"
lua "github.com/yuin/gopher-lua"
)
var routes = make(map[string]string)
var responses = make(map[string]string)
func execute_all_routes(L *lua.LState) {
logger.Debug("Executing all scripts")
for path, script := range routes {
logger.Trace("Executing route: ", path)
execute_route(L, path, script)
}
}
func route(L *lua.LState, request *http.Request) (string, int) {
path := request.URL.Path
// Check if the path is in the routes map
if _, ok := routes[path]; !ok {
return "", http.StatusNotFound
}
// response, _ := execute_route(L, routes[path])
// TODO: This needs to actually get the right base path
response := responses[path]
return response, 200
}