determine tailscale remote user and greet them
1 file changed, 9 insertions(+), 2 deletions(-)
changed files
M domain/content/publisher/app.go → domain/content/publisher/app.go
@@ -6,6 +6,7 @@ "github.com/Southclaws/fault" "github.com/Southclaws/fault/fmsg" "go.hacdias.com/indielib/indieauth" + "tailscale.com/client/local" "alin.ovh/homestead/domain/web/server" "alin.ovh/homestead/domain/web/templates"@@ -17,13 +18,15 @@ type Options struct { Development bool `conf:"-"` BaseURL config.URL - VCSRemoteURL config.URL `conf:"default:https://git.alin.ovh/website"` + VCSRemoteURL config.URL `conf:"default:https://git.alin.ovh/website"` + LocalClient *local.Client `conf:"-"` } type App struct { log *log.Logger indieauthServer *indieauth.Server siteSettings templates.SiteSettings + localClient *local.Client *server.App }@@ -32,6 +35,7 @@ var err error app := &App{ log: log, indieauthServer: indieauth.NewServer(true, &http.Client{}), + localClient: opts.LocalClient, siteSettings: templates.SiteSettings{ Title: "Barkeep", Language: "en-GB",@@ -44,13 +48,16 @@ Shutdown: func() {}, }, } + if opts.BaseURL.Path == "" { + opts.BaseURL.Path = "/" + } err = indieauth.IsValidProfileURL(opts.BaseURL.String()) if err != nil { return nil, fault.Wrap(err, fmsg.With("invalid base URL")) } mux := ihttp.NewServeMux() - mux.HandleFunc("/", app.Index) + mux.HandleFunc("/", app.WithUserContext(app.Index)) mux.HandleFunc("/style.css", app.Style) app.Handler = mux