diff options
author | Brian Picciano <mediocregopher@gmail.com> | 2022-05-20 14:30:09 -0600 |
---|---|---|
committer | Brian Picciano <mediocregopher@gmail.com> | 2022-05-20 14:30:26 -0600 |
commit | af434077ef3a971494fb0bc69ec9617c3b365abd (patch) | |
tree | 2a7c47c9450c2a6b5ac5bcae5c17b33f9a326db9 /srv/src/http/api.go | |
parent | 16cfbd19157df76e7296dddb287412f1099feb33 (diff) |
Implement image macro for rendering images
Diffstat (limited to 'srv/src/http/api.go')
-rw-r--r-- | srv/src/http/api.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/srv/src/http/api.go b/srv/src/http/api.go index abf08e7..8e89c4e 100644 --- a/srv/src/http/api.go +++ b/srv/src/http/api.go @@ -4,6 +4,7 @@ package http import ( "context" "embed" + "encoding/json" "errors" "fmt" "html/template" @@ -57,6 +58,15 @@ type Params struct { func (p *Params) SetupCfg(cfg *cfg.Cfg) { cfg.StringVar(&p.ListenProto, "listen-proto", "tcp", "Protocol to listen for HTTP requests with") cfg.StringVar(&p.ListenAddr, "listen-addr", ":4000", "Address/path to listen for HTTP requests on") + + httpAuthUsersStr := cfg.String("http-auth-users", "{}", "JSON object with usernames as values and password hashes (produced by the hash-password binary) as values. Denotes users which are able to edit server-side data") + + cfg.OnInit(func(context.Context) error { + if err := json.Unmarshal([]byte(*httpAuthUsersStr), &p.AuthUsers); err != nil { + return fmt.Errorf("unmarshaling -http-auth-users: %w", err) + } + return nil + }) } // Annotate implements mctx.Annotator interface. |