Update http config names
This commit is contained in:
parent
1ffda21ae3
commit
b4ca8853a9
@ -6,11 +6,8 @@
|
|||||||
mlSMTPAddr = "";
|
mlSMTPAddr = "";
|
||||||
mlSMTPAuth = "";
|
mlSMTPAuth = "";
|
||||||
mlPublicURL = "http://localhost:4000";
|
mlPublicURL = "http://localhost:4000";
|
||||||
listenProto = "tcp";
|
httpListenProto = "tcp";
|
||||||
listenAddr = ":4000";
|
httpListenAddr = ":4000";
|
||||||
|
|
||||||
# If empty then a derived static directory is used
|
|
||||||
staticProxyURL = "http://127.0.0.1:4002";
|
|
||||||
|
|
||||||
# password is "bar". This should definitely be changed for prod.
|
# password is "bar". This should definitely be changed for prod.
|
||||||
httpAuthUsers = {
|
httpAuthUsers = {
|
||||||
|
@ -26,10 +26,9 @@
|
|||||||
export MEDIOCRE_BLOG_POW_SECRET="${config.powSecret}"
|
export MEDIOCRE_BLOG_POW_SECRET="${config.powSecret}"
|
||||||
|
|
||||||
# http
|
# http
|
||||||
export MEDIOCRE_BLOG_LISTEN_PROTO="${config.listenProto}"
|
export MEDIOCRE_BLOG_LISTEN_PROTO="${config.httpListenProto}"
|
||||||
export MEDIOCRE_BLOG_LISTEN_ADDR="${config.listenAddr}"
|
export MEDIOCRE_BLOG_LISTEN_ADDR="${config.httpListenAddr}"
|
||||||
export MEDIOCRE_BLOG_HTTP_AUTH_USERS='${builtins.toJSON config.httpAuthUsers}'
|
export MEDIOCRE_BLOG_HTTP_AUTH_USERS='${builtins.toJSON config.httpAuthUsers}'
|
||||||
|
|
||||||
export MEDIOCRE_BLOG_HTTP_AUTH_RATELIMIT='${config.httpAuthRatelimit}'
|
export MEDIOCRE_BLOG_HTTP_AUTH_RATELIMIT='${config.httpAuthRatelimit}'
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
@ -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")
|
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")
|
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
|
// initialization
|
||||||
err := cfg.Init(ctx)
|
err := cfg.Init(ctx)
|
||||||
|
|
||||||
@ -72,10 +70,6 @@ func main() {
|
|||||||
"chatGlobalRoomMaxMsgs", *chatGlobalRoomMaxMsgs,
|
"chatGlobalRoomMaxMsgs", *chatGlobalRoomMaxMsgs,
|
||||||
)
|
)
|
||||||
|
|
||||||
if *pathPrefix != "" {
|
|
||||||
ctx = mctx.Annotate(ctx, "pathPrefix", *pathPrefix)
|
|
||||||
}
|
|
||||||
|
|
||||||
clock := clock.Realtime()
|
clock := clock.Realtime()
|
||||||
|
|
||||||
powStore := pow.NewMemoryStore(clock)
|
powStore := pow.NewMemoryStore(clock)
|
||||||
@ -130,7 +124,6 @@ func main() {
|
|||||||
|
|
||||||
httpParams.Logger = logger.WithNamespace("http")
|
httpParams.Logger = logger.WithNamespace("http")
|
||||||
httpParams.PowManager = powMgr
|
httpParams.PowManager = powMgr
|
||||||
httpParams.PathPrefix = *pathPrefix
|
|
||||||
httpParams.PostStore = postStore
|
httpParams.PostStore = postStore
|
||||||
httpParams.PostAssetStore = postAssetStore
|
httpParams.PostAssetStore = postAssetStore
|
||||||
httpParams.MailingList = ml
|
httpParams.MailingList = ml
|
||||||
|
@ -8,6 +8,7 @@ require (
|
|||||||
github.com/emersion/go-smtp v0.15.0
|
github.com/emersion/go-smtp v0.15.0
|
||||||
github.com/gomarkdown/markdown v0.0.0-20220510115730-2372b9aa33e5
|
github.com/gomarkdown/markdown v0.0.0-20220510115730-2372b9aa33e5
|
||||||
github.com/google/uuid v1.3.0
|
github.com/google/uuid v1.3.0
|
||||||
|
github.com/gorilla/feeds v1.1.1 // indirect
|
||||||
github.com/gorilla/websocket v1.4.2
|
github.com/gorilla/websocket v1.4.2
|
||||||
github.com/mattn/go-sqlite3 v1.14.8
|
github.com/mattn/go-sqlite3 v1.14.8
|
||||||
github.com/mediocregopher/mediocre-go-lib/v2 v2.0.0-beta.0.0.20220506011745-cbeee71cb1ee
|
github.com/mediocregopher/mediocre-go-lib/v2 v2.0.0-beta.0.0.20220506011745-cbeee71cb1ee
|
||||||
|
@ -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.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 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
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.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
|
@ -32,10 +32,6 @@ type Params struct {
|
|||||||
Logger *mlog.Logger
|
Logger *mlog.Logger
|
||||||
PowManager pow.Manager
|
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
|
PostStore post.Store
|
||||||
PostAssetStore post.AssetStore
|
PostAssetStore post.AssetStore
|
||||||
|
|
||||||
@ -61,8 +57,8 @@ type Params struct {
|
|||||||
|
|
||||||
// SetupCfg implement the cfg.Cfger interface.
|
// SetupCfg implement the cfg.Cfger interface.
|
||||||
func (p *Params) SetupCfg(cfg *cfg.Cfg) {
|
func (p *Params) SetupCfg(cfg *cfg.Cfg) {
|
||||||
cfg.StringVar(&p.ListenProto, "listen-proto", "tcp", "Protocol to listen for HTTP requests with")
|
cfg.StringVar(&p.ListenProto, "http-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.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")
|
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")
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ func (a *api) parseTpl(tplBody string) (*template.Template, error) {
|
|||||||
// filepath.Join strips trailing slash, but we want to keep it
|
// filepath.Join strips trailing slash, but we want to keep it
|
||||||
trailingSlash := strings.HasSuffix(path, "/")
|
trailingSlash := strings.HasSuffix(path, "/")
|
||||||
|
|
||||||
path = filepath.Join("/", a.params.PathPrefix, path)
|
path = filepath.Join("/", path)
|
||||||
|
|
||||||
if trailingSlash && path != "/" {
|
if trailingSlash && path != "/" {
|
||||||
path += "/"
|
path += "/"
|
||||||
|
Loading…
Reference in New Issue
Block a user