summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authordemo <demo@antix1>2026-05-07 15:46:26 -0400
committerdemo <demo@antix1>2026-05-07 15:46:26 -0400
commit5aecda4a8006c74e8c912d937fb9b282630bb883 (patch)
tree3f6a60c5e7c6e174476c2816a361f4e9d8415695 /internal
parent9c1d8f97aae6454d86c6efdfde03e17cf7ea61ed (diff)
feat: implement basic page-infrastructure
Diffstat (limited to 'internal')
-rw-r--r--internal/types/types.go21
1 files changed, 14 insertions, 7 deletions
diff --git a/internal/types/types.go b/internal/types/types.go
index 3772f1f..b431eaf 100644
--- a/internal/types/types.go
+++ b/internal/types/types.go
@@ -1,8 +1,8 @@
package types
import (
+ "fmt"
"html/template"
- "io"
"net/http"
)
@@ -20,14 +20,21 @@ type arc struct {
type story map[string]arc
type Config struct {
- Story story
- Template *template.Template
+ *template.Template
+ Story story
}
func (cfg Config) ServeHTTP(w http.ResponseWriter, r *http.Request) {
- arc := r.PathValue("arc")
- title := cfg.Story[arc].Title
+ arcName := r.PathValue("arc")
+ arc, ok := cfg.Story[arcName]
+ if !ok {
+ msg := fmt.Sprintf("Arc with name %s doesn't exist", arcName)
+ http.Error(w, msg, http.StatusNotFound)
+ return
+ }
- w.Header().Set("Content-Type", "text/plain")
- io.WriteString(w, title)
+ w.Header().Set("Content-Type", "text/html")
+ if err := cfg.ExecuteTemplate(w, "index", arc); err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ }
}