summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordemo <demo@antix1>2026-05-07 13:51:29 -0400
committerdemo <demo@antix1>2026-05-07 13:51:29 -0400
commit8b3d93fb01ea63b8daf77861fef1be837276652a (patch)
tree11bac35b7e00fd3ab89a8327bb5f82bc3107b2d3
parent44911fb0c2ae616cf07f46e35192d7f297bccf4b (diff)
refactor: move type defs and ServeHTTP def to internal package
-rw-r--r--internal/types/types.go27
-rw-r--r--main.go25
2 files changed, 30 insertions, 22 deletions
diff --git a/internal/types/types.go b/internal/types/types.go
new file mode 100644
index 0000000..0800994
--- /dev/null
+++ b/internal/types/types.go
@@ -0,0 +1,27 @@
+package types
+
+import (
+ "io"
+ "net/http"
+)
+
+type option struct {
+ Text string
+ Arc string
+}
+
+type arc struct {
+ Title string
+ Story []string
+ Options []option
+}
+
+type Story map[string]arc
+
+func (s Story) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ arc := r.PathValue("arc")
+ title := s[arc].Title
+
+ w.Header().Set("Content-Type", "text/plain")
+ io.WriteString(w, title)
+}
diff --git a/main.go b/main.go
index 14dec49..65d9321 100644
--- a/main.go
+++ b/main.go
@@ -7,28 +7,9 @@ import (
"log"
"net/http"
"os"
-)
-
-type option struct {
- Text string
- Arc string
-}
-
-type arc struct {
- Title string
- Story []string
- Options []option
-}
-type story map[string]arc
-
-func (s story) ServeHTTP(w http.ResponseWriter, r *http.Request) {
- arc := r.PathValue("arc")
- title := s[arc].Title
-
- w.Header().Set("Content-Type", "text/plain")
- io.WriteString(w, title)
-}
+ "git.brandonirizarry.xyz/adventure/internal/types"
+)
func main() {
// Set up log flags.
@@ -50,7 +31,7 @@ func main() {
log.Fatal(err)
}
- var s story
+ var s types.Story
if err := json.Unmarshal(jsonBytes, &s); err != nil {
log.Fatal(err)
}