ok we got basicauth and / serves index

main
Bel LaPointe 2024-02-20 08:07:59 -07:00
parent 9be5d8235e
commit ec8d451df8
1 changed files with 17 additions and 0 deletions

View File

@ -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")
}