diff options
Diffstat (limited to '')
-rw-r--r-- | auth.go (renamed from backend/auth.go) | 0 | ||||
-rw-r--r-- | backend/Makefile | 3 | ||||
-rw-r--r-- | config.go (renamed from backend/config.go) | 21 | ||||
-rw-r--r-- | courses.go (renamed from backend/courses.go) | 0 | ||||
-rw-r--r-- | db.go (renamed from backend/db.go) | 0 | ||||
-rw-r--r-- | go.mod (renamed from backend/go.mod) | 0 | ||||
-rw-r--r-- | go.sum (renamed from backend/go.sum) | 0 | ||||
-rw-r--r-- | index.go (renamed from backend/index.go) | 3 | ||||
-rw-r--r-- | main.go (renamed from backend/main.go) | 34 | ||||
-rw-r--r-- | usem.go (renamed from backend/usem.go) | 0 | ||||
-rw-r--r-- | utils.go (renamed from backend/utils.go) | 0 | ||||
-rw-r--r-- | wsc.go (renamed from backend/wsc.go) | 0 | ||||
-rw-r--r-- | wsh.go (renamed from backend/wsh.go) | 0 | ||||
-rw-r--r-- | wsm.go (renamed from backend/wsm.go) | 0 | ||||
-rw-r--r-- | wsp.go (renamed from backend/wsp.go) | 0 | ||||
-rw-r--r-- | wsx.go (renamed from backend/wsx.go) | 0 |
16 files changed, 31 insertions, 30 deletions
diff --git a/backend/auth.go b/auth.go index 9ef1254..9ef1254 100644 --- a/backend/auth.go +++ b/auth.go diff --git a/backend/Makefile b/backend/Makefile deleted file mode 100644 index 22c6e5f..0000000 --- a/backend/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -../dist/cca: *.go - mkdir -p ../dist - go build -o ../dist/cca diff --git a/backend/config.go b/config.go index e5bea02..f1e48e9 100644 --- a/backend/config.go +++ b/config.go @@ -41,9 +41,6 @@ import ( var configWithPointers struct { URL *string `scfg:"url"` Prod *bool `scfg:"prod"` - Tmpl *string `scfg:"tmpl"` - Static *string `scfg:"static"` - Source *string `scfg:"source"` Listen struct { Proto *string `scfg:"proto"` Net *string `scfg:"net"` @@ -78,9 +75,6 @@ var configWithPointers struct { var config struct { URL string Prod bool - Tmpl string - Static string - Source string Listen struct { Proto string Net string @@ -156,21 +150,6 @@ func fetchConfig(path string) (retErr error) { } config.Prod = *(configWithPointers.Prod) - if configWithPointers.Tmpl == nil { - return fmt.Errorf("%w: tmpl", errMissingConfigValue) - } - config.Tmpl = *(configWithPointers.Tmpl) - - if configWithPointers.Static == nil { - return fmt.Errorf("%w: static", errMissingConfigValue) - } - config.Static = *(configWithPointers.Static) - - if configWithPointers.Source == nil { - return fmt.Errorf("%w: source", errMissingConfigValue) - } - config.Source = *(configWithPointers.Source) - if configWithPointers.Listen.Proto == nil { return fmt.Errorf("%w: listen.proto", errMissingConfigValue) } diff --git a/backend/courses.go b/courses.go index 4e1ea51..4e1ea51 100644 --- a/backend/courses.go +++ b/courses.go diff --git a/backend/index.go b/index.go index f446072..a75f3d2 100644 --- a/backend/index.go +++ b/index.go @@ -46,7 +46,6 @@ func handleIndex(w http.ResponseWriter, req *http.Request) { "login", map[string]string{ "authURL": authURL, - "source": config.Source, /* * We directly generate the login URL here * instead of doing so in a redirect to save @@ -83,7 +82,6 @@ func handleIndex(w http.ResponseWriter, req *http.Request) { map[string]interface{}{ "authURL": authURL, "notes": "You sent an invalid session cookie.", - "source": config.Source, }, ) if err != nil { @@ -109,7 +107,6 @@ func handleIndex(w http.ResponseWriter, req *http.Request) { "Department": userDepartment, }, "courses": courses, - "source": config.Source, }, ) }() diff --git a/backend/main.go b/main.go index a185de9..20e7fe2 100644 --- a/backend/main.go +++ b/main.go @@ -22,7 +22,9 @@ package main import ( "crypto/tls" + "embed" "flag" + "io/fs" "html/template" "log" "net" @@ -32,6 +34,12 @@ import ( var tmpl *template.Template +//go:embed build/static/* tmpl/* build/iadocs/* build/docs/* +var runFS embed.FS + +//go:embed *.go docs/* frontend/* README.md LICENSE Makefile iadocs/* sql/* tmpl/* scripts/* +var srcFS embed.FS + func main() { var err error @@ -55,7 +63,7 @@ func main() { } log.Println("Setting up templates") - tmpl, err = template.ParseGlob(config.Tmpl) + tmpl, err = template.ParseFS(runFS, "tmpl/*") if err != nil { log.Fatal(err) } @@ -67,8 +75,28 @@ func main() { } log.Println("Registering static handle") - fs := http.FileServer(http.Dir(config.Static)) - http.Handle("/static/", http.StripPrefix("/static/", fs)) + staticFS, err := fs.Sub(runFS, "build/static") + if err != nil { + log.Fatal(err) + } + http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.FS(staticFS)))) + + log.Println("Registering iadocs handle") + iaDocsFS, err := fs.Sub(runFS, "build/iadocs") + if err != nil { + log.Fatal(err) + } + http.Handle("/iadocs/", http.StripPrefix("/iadocs/", http.FileServer(http.FS(iaDocsFS)))) + + log.Println("Registering docs handle") + docsFS, err := fs.Sub(runFS, "build/docs") + if err != nil { + log.Fatal(err) + } + http.Handle("/docs/", http.StripPrefix("/docs/", http.FileServer(http.FS(docsFS)))) + + log.Println("Registering source handle") + http.Handle("/src/", http.StripPrefix("/src/", http.FileServer(http.FS(srcFS)))) log.Println("Registering handlers") http.HandleFunc("/{$}", handleIndex) diff --git a/backend/usem.go b/usem.go index 0b839a4..0b839a4 100644 --- a/backend/usem.go +++ b/usem.go diff --git a/backend/utils.go b/utils.go index 3628c80..3628c80 100644 --- a/backend/utils.go +++ b/utils.go |