aboutsummaryrefslogtreecommitdiff
path: root/forged/internal/incoming/web/stub.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-08-17 16:10:12 +0800
committerRunxi Yu <me@runxiyu.org>2025-08-17 16:10:12 +0800
commitba43cd193c78eb70c4734d95f5864bfffde3277d (patch)
tree3158ecc58822dfeda4a4bd98b2023cb642d0b158 /forged/internal/incoming/web/stub.go
parentSplit the handler up (diff)
downloadforge-ba43cd193c78eb70c4734d95f5864bfffde3277d.tar.gz
forge-ba43cd193c78eb70c4734d95f5864bfffde3277d.tar.zst
forge-ba43cd193c78eb70c4734d95f5864bfffde3277d.zip
Unspaghetti the handler
Diffstat (limited to 'forged/internal/incoming/web/stub.go')
-rw-r--r--forged/internal/incoming/web/stub.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/forged/internal/incoming/web/stub.go b/forged/internal/incoming/web/stub.go
new file mode 100644
index 0000000..7207756
--- /dev/null
+++ b/forged/internal/incoming/web/stub.go
@@ -0,0 +1,44 @@
+package web
+
+import (
+ "fmt"
+ "net/http"
+ "strings"
+)
+
+func (h *handler) index(w http.ResponseWriter, r *http.Request, p Params) {
+ _, _ = w.Write([]byte("index: replace with template render"))
+}
+
+func (h *handler) groupIndex(w http.ResponseWriter, r *http.Request, p Params) {
+ g := p["group_path"].([]string) // captured by @group
+ _, _ = w.Write([]byte("group index for: /" + strings.Join(g, "/") + "/"))
+}
+
+func (h *handler) repoIndex(w http.ResponseWriter, r *http.Request, p Params) {
+ repo := p["repo"].(string)
+ g := p["group_path"].([]string)
+ _, _ = w.Write([]byte(fmt.Sprintf("repo index: group=%q repo=%q", "/"+strings.Join(g, "/")+"/", repo)))
+}
+
+func (h *handler) repoTree(w http.ResponseWriter, r *http.Request, p Params) {
+ repo := p["repo"].(string)
+ rest := p["rest"].(string) // may be ""
+ if p["dir_mode"].(bool) && rest != "" && !strings.HasSuffix(rest, "/") {
+ rest += "/"
+ }
+ _, _ = w.Write([]byte(fmt.Sprintf("tree: repo=%q path=%q", repo, rest)))
+}
+
+func (h *handler) repoRaw(w http.ResponseWriter, r *http.Request, p Params) {
+ repo := p["repo"].(string)
+ rest := p["rest"].(string)
+ if p["dir_mode"].(bool) && rest != "" && !strings.HasSuffix(rest, "/") {
+ rest += "/"
+ }
+ _, _ = w.Write([]byte(fmt.Sprintf("raw: repo=%q path=%q", repo, rest)))
+}
+
+func (h *handler) notImplemented(w http.ResponseWriter, _ *http.Request, _ Params) {
+ http.Error(w, "not implemented", http.StatusNotImplemented)
+}