summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2022-05-20 17:04:20 -0600
committerBrian Picciano <mediocregopher@gmail.com>2022-05-20 17:04:20 -0600
commitb4ca8853a9085cb0231f2c4de25a1ec07ef150a0 (patch)
tree266efcf8611cc47aae235a011b7bb30d5b5499a7
parent1ffda21ae38d203e381bedbf7bdbbd69c9031062 (diff)
Update http config names
-rw-r--r--config.nix7
-rw-r--r--srv/default.nix5
-rw-r--r--srv/src/cmd/mediocre-blog/main.go7
-rw-r--r--srv/src/go.mod1
-rw-r--r--srv/src/go.sum2
-rw-r--r--srv/src/http/api.go8
-rw-r--r--srv/src/http/tpl.go2
7 files changed, 10 insertions, 22 deletions
diff --git a/config.nix b/config.nix
index e6b6697..674ba37 100644
--- a/config.nix
+++ b/config.nix
@@ -6,11 +6,8 @@
mlSMTPAddr = "";
mlSMTPAuth = "";
mlPublicURL = "http://localhost:4000";
- listenProto = "tcp";
- listenAddr = ":4000";
-
- # If empty then a derived static directory is used
- staticProxyURL = "http://127.0.0.1:4002";
+ httpListenProto = "tcp";
+ httpListenAddr = ":4000";
# password is "bar". This should definitely be changed for prod.
httpAuthUsers = {
diff --git a/srv/default.nix b/srv/default.nix
index c55a987..7ca70e8 100644
--- a/srv/default.nix
+++ b/srv/default.nix
@@ -26,10 +26,9 @@
export MEDIOCRE_BLOG_POW_SECRET="${config.powSecret}"
# http
- export MEDIOCRE_BLOG_LISTEN_PROTO="${config.listenProto}"
- export MEDIOCRE_BLOG_LISTEN_ADDR="${config.listenAddr}"
+ export MEDIOCRE_BLOG_LISTEN_PROTO="${config.httpListenProto}"
+ export MEDIOCRE_BLOG_LISTEN_ADDR="${config.httpListenAddr}"
export MEDIOCRE_BLOG_HTTP_AUTH_USERS='${builtins.toJSON config.httpAuthUsers}'
-
export MEDIOCRE_BLOG_HTTP_AUTH_RATELIMIT='${config.httpAuthRatelimit}'
'';
diff --git a/srv/src/cmd/mediocre-blog/main.go b/srv/src/cmd/mediocre-blog/main.go
index ce43c61..b855110 100644
--- a/srv/src/cmd/mediocre-blog/main.go
+++ b/srv/src/cmd/mediocre-blog/main.go
@@ -53,8 +53,6 @@ func main() {
chatGlobalRoomMaxMsgs := cfg.Int("chat-global-room-max-messages", 1000, "Maximum number of messages the global chat room can retain")
chatUserIDCalcSecret := cfg.String("chat-user-id-calc-secret", "", "Secret to use when calculating user ids")
- pathPrefix := cfg.String("path-prefix", "", "Prefix which is optionally applied to all URL paths rendered by the blog")
-
// initialization
err := cfg.Init(ctx)
@@ -72,10 +70,6 @@ func main() {
"chatGlobalRoomMaxMsgs", *chatGlobalRoomMaxMsgs,
)
- if *pathPrefix != "" {
- ctx = mctx.Annotate(ctx, "pathPrefix", *pathPrefix)
- }
-
clock := clock.Realtime()
powStore := pow.NewMemoryStore(clock)
@@ -130,7 +124,6 @@ func main() {
httpParams.Logger = logger.WithNamespace("http")
httpParams.PowManager = powMgr
- httpParams.PathPrefix = *pathPrefix
httpParams.PostStore = postStore
httpParams.PostAssetStore = postAssetStore
httpParams.MailingList = ml
diff --git a/srv/src/go.mod b/srv/src/go.mod
index be8d39e..dd6509d 100644
--- a/srv/src/go.mod
+++ b/srv/src/go.mod
@@ -8,6 +8,7 @@ require (
github.com/emersion/go-smtp v0.15.0
github.com/gomarkdown/markdown v0.0.0-20220510115730-2372b9aa33e5
github.com/google/uuid v1.3.0
+ github.com/gorilla/feeds v1.1.1 // indirect
github.com/gorilla/websocket v1.4.2
github.com/mattn/go-sqlite3 v1.14.8
github.com/mediocregopher/mediocre-go-lib/v2 v2.0.0-beta.0.0.20220506011745-cbeee71cb1ee
diff --git a/srv/src/go.sum b/srv/src/go.sum
index c0b0014..f5bd1fe 100644
--- a/srv/src/go.sum
+++ b/srv/src/go.sum
@@ -65,6 +65,8 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/gorilla/feeds v1.1.1 h1:HwKXxqzcRNg9to+BbvJog4+f3s/xzvtZXICcQGutYfY=
+github.com/gorilla/feeds v1.1.1/go.mod h1:Nk0jZrvPFZX1OBe5NPiddPw7CfwF6Q9eqzaBbaightA=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
diff --git a/srv/src/http/api.go b/srv/src/http/api.go
index 85a6375..ab0e972 100644
--- a/srv/src/http/api.go
+++ b/srv/src/http/api.go
@@ -32,10 +32,6 @@ type Params struct {
Logger *mlog.Logger
PowManager pow.Manager
- // PathPrefix, if given, will be prefixed to all url paths which are
- // rendered by the API's templating system.
- PathPrefix string
-
PostStore post.Store
PostAssetStore post.AssetStore
@@ -61,8 +57,8 @@ type Params struct {
// SetupCfg implement the cfg.Cfger interface.
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")
+ cfg.StringVar(&p.ListenProto, "http-listen-proto", "tcp", "Protocol to listen for HTTP requests with")
+ cfg.StringVar(&p.ListenAddr, "http-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")
diff --git a/srv/src/http/tpl.go b/srv/src/http/tpl.go
index 62a4d06..dcd1551 100644
--- a/srv/src/http/tpl.go
+++ b/srv/src/http/tpl.go
@@ -35,7 +35,7 @@ func (a *api) parseTpl(tplBody string) (*template.Template, error) {
// filepath.Join strips trailing slash, but we want to keep it
trailingSlash := strings.HasSuffix(path, "/")
- path = filepath.Join("/", a.params.PathPrefix, path)
+ path = filepath.Join("/", path)
if trailingSlash && path != "/" {
path += "/"