ok we got basicauth and / serves index
parent
9be5d8235e
commit
ec8d451df8
|
|
@ -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")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue