From ec8d451df839a4273f0ffd02e10e33ae5b68fe04 Mon Sep 17 00:00:00 2001 From: Bel LaPointe <153096461+breel-render@users.noreply.github.com> Date: Tue, 20 Feb 2024 08:07:59 -0700 Subject: [PATCH] ok we got basicauth and / serves index --- cmd/server/main.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cmd/server/main.go b/cmd/server/main.go index 31e62e9..c9f3a3b 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -2,14 +2,17 @@ package main import ( "context" + "embed" "encoding/base64" "errors" "flag" "fmt" + "io/fs" "log" "net/http" "os" "os/signal" + "strings" "syscall" "golang.org/x/time/rate" @@ -120,6 +123,20 @@ func (h Handler) auth(r *http.Request) (Session, error) { return session, nil } +//go:embed internal/public +var _public embed.FS +var public = func() http.FileSystem { + d, err := fs.Sub(_public, "internal/public") + if err != nil { + panic(err) + } + return http.FS(d) +}() + func (h Handler) handle(session Session, w http.ResponseWriter, r *http.Request) error { + if !strings.HasPrefix(r.URL.Path, "/api") { + http.FileServer(public).ServeHTTP(w, r) + return nil + } return errors.New("not impl") }