Compare commits
No commits in common. "6f20540720318e6277bddcea12d520a5d6e76561" and "cc2cb0c682496f91b263054a668e5c8bf4cfb43c" have entirely different histories.
6f20540720
...
cc2cb0c682
@ -234,13 +234,13 @@ func handleRequest(ctx *fasthttp.RequestCtx) {
|
||||
req.Path = path
|
||||
req.Body = string(ctx.Request.Body())
|
||||
|
||||
for key, value := range ctx.QueryArgs().All() {
|
||||
ctx.QueryArgs().VisitAll(func(key, value []byte) {
|
||||
req.Query[string(key)] = string(value)
|
||||
}
|
||||
})
|
||||
|
||||
for key, value := range ctx.Request.Header.All() {
|
||||
ctx.Request.Header.VisitAll(func(key, value []byte) {
|
||||
req.Headers[string(key)] = string(value)
|
||||
}
|
||||
})
|
||||
|
||||
err := worker.HandleRequest(req, resp)
|
||||
if err != nil {
|
||||
@ -277,8 +277,8 @@ func tryStaticHandler(ctx *fasthttp.RequestCtx, path string) bool {
|
||||
defer staticMu.RUnlock()
|
||||
|
||||
for prefix, fs := range staticHandlers {
|
||||
if after, ok := strings.CutPrefix(path, prefix); ok {
|
||||
ctx.Request.URI().SetPath(after)
|
||||
if strings.HasPrefix(path, prefix) {
|
||||
ctx.Request.URI().SetPath(strings.TrimPrefix(path, prefix))
|
||||
fs.NewRequestHandler()(ctx)
|
||||
return true
|
||||
}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
-- modules/http.lua - Express-like HTTP server with pure Lua routing
|
||||
|
||||
local http = {}
|
||||
local json = require("json")
|
||||
|
||||
-- Global routing tables (shared across all states)
|
||||
_G._http_routes = _G._http_routes or {}
|
||||
@ -309,7 +308,7 @@ function Request:json()
|
||||
end
|
||||
|
||||
local success, result = pcall(function()
|
||||
return json.decode(self.body)
|
||||
return moonshark.json_decode(self.body)
|
||||
end)
|
||||
|
||||
if success then
|
||||
@ -392,7 +391,7 @@ function Response:json(data)
|
||||
self:type("application/json")
|
||||
|
||||
local success, json_str = pcall(function()
|
||||
return json.encode(data)
|
||||
return moonshark.json_encode(data)
|
||||
end)
|
||||
|
||||
if success then
|
||||
|
||||
@ -30,7 +30,11 @@ func string_slice(s *luajit.State) int {
|
||||
|
||||
runes := []rune(str)
|
||||
length := len(runes)
|
||||
startIdx := max(start-1, 0) // Convert from 1-indexed
|
||||
startIdx := start - 1 // Convert from 1-indexed
|
||||
|
||||
if startIdx < 0 {
|
||||
startIdx = 0
|
||||
}
|
||||
if startIdx >= length {
|
||||
s.PushString("")
|
||||
return 1
|
||||
|
||||
@ -259,7 +259,7 @@ func (s *State) ExecuteStringWithResults(code, name string) ([]any, error) {
|
||||
}
|
||||
|
||||
results := make([]any, nresults)
|
||||
for i := range nresults {
|
||||
for i := 0; i < nresults; i++ {
|
||||
val, err := s.ToValue(baseTop + i + 1)
|
||||
if err != nil {
|
||||
results[i] = nil
|
||||
|
||||
@ -3,7 +3,6 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"maps"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@ -85,7 +84,9 @@ func (fw *FileWatcher) pollLoop() {
|
||||
func (fw *FileWatcher) checkFiles() {
|
||||
fw.mu.RLock()
|
||||
files := make(map[string]time.Time, len(fw.files))
|
||||
maps.Copy(files, fw.files)
|
||||
for path, modTime := range fw.files {
|
||||
files[path] = modTime
|
||||
}
|
||||
fw.mu.RUnlock()
|
||||
|
||||
changed := false
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user