diff options
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/lume/lume.go | 10 | ||||
| -rw-r--r-- | internal/passwdmiddleware.go | 15 |
2 files changed, 23 insertions, 2 deletions
diff --git a/internal/lume/lume.go b/internal/lume/lume.go index a575d2b..aa84abe 100644 --- a/internal/lume/lume.go +++ b/internal/lume/lume.go @@ -4,6 +4,7 @@ import ( "archive/zip" "context" "encoding/json" + "errors" "expvar" "fmt" "html/template" @@ -251,8 +252,13 @@ func (f *FS) Update(ctx context.Context) error { ReferenceName: plumbing.NewBranchReferenceName(f.opt.Branch), }) if err != nil { - updateErrors.Add(1) - return err + switch { + case errors.Is(err, git.NoErrAlreadyUpToDate): + slog.Debug("already up to date") + default: + updateErrors.Add(1) + return err + } } err = wt.Checkout(&git.CheckoutOptions{ diff --git a/internal/passwdmiddleware.go b/internal/passwdmiddleware.go new file mode 100644 index 0000000..8fa511a --- /dev/null +++ b/internal/passwdmiddleware.go @@ -0,0 +1,15 @@ +package internal + +import "net/http" + +func PasswordMiddleware(username, password string, next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + user, pass, ok := r.BasicAuth() + if !ok || user != username || pass != password { + http.Error(w, "Unauthorized", http.StatusUnauthorized) + return + } + + next.ServeHTTP(w, r) + }) +} |
