summaryrefslogtreecommitdiff
path: root/internal/types/types.go
blob: 3772f1f4f6ce34e53243c45eb9f9b6c6855af426 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package types

import (
	"html/template"
	"io"
	"net/http"
)

type option struct {
	Text string
	Arc  string
}

type arc struct {
	Title   string
	Story   []string
	Options []option
}

type story map[string]arc

type Config struct {
	Story    story
	Template *template.Template
}

func (cfg Config) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	arc := r.PathValue("arc")
	title := cfg.Story[arc].Title

	w.Header().Set("Content-Type", "text/plain")
	io.WriteString(w, title)
}