open read-only access to /a, /m, /t, /sk; preserve blank lines
- Allow GET/HEAD on agent, memory, tool, skill paths - Preserve empty lines in multi-line file content
This commit is contained in:
parent
830849e193
commit
14bcbf0646
15
main.go
15
main.go
|
|
@ -105,11 +105,20 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// Internal paths not exposed via HTTP.
|
||||
first, _, _ := strings.Cut(p, "/")
|
||||
// Paths never exposed via HTTP.
|
||||
switch first {
|
||||
case "", "a", "p", "m", "t", "sk", "help", "tr", "u", "x", "tmp":
|
||||
case "p", "help", "tr", "u", "x", "tmp":
|
||||
writeJSON(w, http.StatusNotFound, map[string]string{"error": "not found"})
|
||||
return
|
||||
}
|
||||
// Read-only paths — only GET and HEAD allowed.
|
||||
switch first {
|
||||
case "", "a", "m", "t", "sk":
|
||||
if r.Method != http.MethodGet && r.Method != http.MethodHead {
|
||||
writeJSON(w, http.StatusMethodNotAllowed, map[string]string{"error": "read-only"})
|
||||
return
|
||||
}
|
||||
}
|
||||
base := path.Base(p)
|
||||
switch base {
|
||||
case "systemprompt", "statewait":
|
||||
|
|
@ -288,9 +297,7 @@ func parseContent(data []byte, name string) any {
|
|||
}
|
||||
var lines []string
|
||||
for line := range strings.SplitSeq(s, "\n") {
|
||||
if line != "" {
|
||||
lines = append(lines, line)
|
||||
}
|
||||
lines = append(lines, line)
|
||||
}
|
||||
if len(lines) == 1 {
|
||||
return map[string]string{name: lines[0]}
|
||||
|
|
|
|||
Loading…
Reference in New Issue