summaryrefslogtreecommitdiff
path: root/srv/src
diff options
context:
space:
mode:
Diffstat (limited to 'srv/src')
-rw-r--r--srv/src/cmd/hash-password/main.go4
-rw-r--r--srv/src/cmd/mediocre-blog/main.go42
-rw-r--r--srv/src/http/api.go (renamed from srv/src/api/api.go)4
-rw-r--r--srv/src/http/apiutil/apiutil.go (renamed from srv/src/api/apiutil/apiutil.go)0
-rw-r--r--srv/src/http/assets.go (renamed from srv/src/api/assets.go)4
-rw-r--r--srv/src/http/auth.go (renamed from srv/src/api/auth.go)4
-rw-r--r--srv/src/http/auth_test.go (renamed from srv/src/api/auth_test.go)2
-rw-r--r--srv/src/http/chat.go (renamed from srv/src/api/chat.go)4
-rw-r--r--srv/src/http/csrf.go (renamed from srv/src/api/csrf.go)4
-rw-r--r--srv/src/http/index.go (renamed from srv/src/api/index.go)4
-rw-r--r--srv/src/http/mailinglist.go (renamed from srv/src/api/mailinglist.go)4
-rw-r--r--srv/src/http/middleware.go (renamed from srv/src/api/middleware.go)4
-rw-r--r--srv/src/http/posts.go (renamed from srv/src/api/posts.go)4
-rw-r--r--srv/src/http/pow.go (renamed from srv/src/api/pow.go)4
-rw-r--r--srv/src/http/tpl.go (renamed from srv/src/api/tpl.go)4
-rw-r--r--srv/src/http/tpl/assets.html (renamed from srv/src/api/tpl/assets.html)0
-rw-r--r--srv/src/http/tpl/base.html (renamed from srv/src/api/tpl/base.html)0
-rw-r--r--srv/src/http/tpl/edit-post.html (renamed from srv/src/api/tpl/edit-post.html)0
-rw-r--r--srv/src/http/tpl/follow.html (renamed from srv/src/api/tpl/follow.html)0
-rw-r--r--srv/src/http/tpl/index.html (renamed from srv/src/api/tpl/index.html)0
-rw-r--r--srv/src/http/tpl/post.html (renamed from srv/src/api/tpl/post.html)0
-rw-r--r--srv/src/http/tpl/posts.html (renamed from srv/src/api/tpl/posts.html)0
-rw-r--r--srv/src/http/tpl/redirect.html (renamed from srv/src/api/tpl/redirect.html)0
23 files changed, 46 insertions, 46 deletions
diff --git a/srv/src/cmd/hash-password/main.go b/srv/src/cmd/hash-password/main.go
index b787a4d..47ae1e7 100644
--- a/srv/src/cmd/hash-password/main.go
+++ b/srv/src/cmd/hash-password/main.go
@@ -6,7 +6,7 @@ import (
"os"
"strings"
- "github.com/mediocregopher/blog.mediocregopher.com/srv/api"
+ "github.com/mediocregopher/blog.mediocregopher.com/srv/http"
)
func main() {
@@ -19,5 +19,5 @@ func main() {
panic(err)
}
- fmt.Println(api.NewPasswordHash(strings.TrimSpace(line)))
+ fmt.Println(http.NewPasswordHash(strings.TrimSpace(line)))
}
diff --git a/srv/src/cmd/mediocre-blog/main.go b/srv/src/cmd/mediocre-blog/main.go
index 5cb4d5f..f76188b 100644
--- a/srv/src/cmd/mediocre-blog/main.go
+++ b/srv/src/cmd/mediocre-blog/main.go
@@ -8,9 +8,9 @@ import (
"syscall"
"time"
- "github.com/mediocregopher/blog.mediocregopher.com/srv/api"
cfgpkg "github.com/mediocregopher/blog.mediocregopher.com/srv/cfg"
"github.com/mediocregopher/blog.mediocregopher.com/srv/chat"
+ "github.com/mediocregopher/blog.mediocregopher.com/srv/http"
"github.com/mediocregopher/blog.mediocregopher.com/srv/mailinglist"
"github.com/mediocregopher/blog.mediocregopher.com/srv/post"
"github.com/mediocregopher/blog.mediocregopher.com/srv/pow"
@@ -42,9 +42,9 @@ func main() {
mlParams.SetupCfg(cfg)
ctx = mctx.WithAnnotator(ctx, &mlParams)
- var apiParams api.Params
- apiParams.SetupCfg(cfg)
- ctx = mctx.WithAnnotator(ctx, &apiParams)
+ var httpParams http.Params
+ httpParams.SetupCfg(cfg)
+ ctx = mctx.WithAnnotator(ctx, &httpParams)
var radixClient cfgpkg.RadixClient
radixClient.SetupCfg(cfg)
@@ -56,7 +56,7 @@ func main() {
pathPrefix := cfg.String("path-prefix", "", "Prefix which is optionally applied to all URL paths rendered by the blog")
- apiAuthUsersStr := cfg.String("api-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")
// initialization
err := cfg.Init(ctx)
@@ -131,32 +131,32 @@ func main() {
postStore := post.NewStore(postSQLDB)
postAssetStore := post.NewAssetStore(postSQLDB)
- var apiAuthUsers map[string]string
- if err := json.Unmarshal([]byte(*apiAuthUsersStr), &apiAuthUsers); err != nil {
- logger.Fatal(ctx, "unmarshaling -api-auth-users", err)
+ var httpAuthUsers map[string]string
+ if err := json.Unmarshal([]byte(*httpAuthUsersStr), &httpAuthUsers); err != nil {
+ logger.Fatal(ctx, "unmarshaling -http-auth-users", err)
}
- apiParams.Logger = logger.WithNamespace("api")
- apiParams.PowManager = powMgr
- apiParams.PathPrefix = *pathPrefix
- apiParams.PostStore = postStore
- apiParams.PostAssetStore = postAssetStore
- apiParams.MailingList = ml
- apiParams.GlobalRoom = chatGlobalRoom
- apiParams.UserIDCalculator = chatUserIDCalc
- apiParams.AuthUsers = apiAuthUsers
+ httpParams.Logger = logger.WithNamespace("http")
+ httpParams.PowManager = powMgr
+ httpParams.PathPrefix = *pathPrefix
+ httpParams.PostStore = postStore
+ httpParams.PostAssetStore = postAssetStore
+ httpParams.MailingList = ml
+ httpParams.GlobalRoom = chatGlobalRoom
+ httpParams.UserIDCalculator = chatUserIDCalc
+ httpParams.AuthUsers = httpAuthUsers
logger.Info(ctx, "listening")
- a, err := api.New(apiParams)
+ httpAPI, err := http.New(httpParams)
if err != nil {
- logger.Fatal(ctx, "initializing api", err)
+ logger.Fatal(ctx, "initializing http api", err)
}
defer func() {
shutdownCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
- if err := a.Shutdown(shutdownCtx); err != nil {
- logger.Fatal(ctx, "shutting down api", err)
+ if err := httpAPI.Shutdown(shutdownCtx); err != nil {
+ logger.Fatal(ctx, "shutting down http api", err)
}
}()
diff --git a/srv/src/api/api.go b/srv/src/http/api.go
index 191a7bf..bbf4419 100644
--- a/srv/src/api/api.go
+++ b/srv/src/http/api.go
@@ -1,5 +1,5 @@
// Package api implements the HTTP-based api for the mediocre-blog.
-package api
+package http
import (
"context"
@@ -12,9 +12,9 @@ import (
"net/url"
"os"
- "github.com/mediocregopher/blog.mediocregopher.com/srv/api/apiutil"
"github.com/mediocregopher/blog.mediocregopher.com/srv/cfg"
"github.com/mediocregopher/blog.mediocregopher.com/srv/chat"
+ "github.com/mediocregopher/blog.mediocregopher.com/srv/http/apiutil"
"github.com/mediocregopher/blog.mediocregopher.com/srv/mailinglist"
"github.com/mediocregopher/blog.mediocregopher.com/srv/post"
"github.com/mediocregopher/blog.mediocregopher.com/srv/pow"
diff --git a/srv/src/api/apiutil/apiutil.go b/srv/src/http/apiutil/apiutil.go
index d427b65..d427b65 100644
--- a/srv/src/api/apiutil/apiutil.go
+++ b/srv/src/http/apiutil/apiutil.go
diff --git a/srv/src/api/assets.go b/srv/src/http/assets.go
index 47be14c..f782c69 100644
--- a/srv/src/api/assets.go
+++ b/srv/src/http/assets.go
@@ -1,4 +1,4 @@
-package api
+package http
import (
"bytes"
@@ -12,7 +12,7 @@ import (
"path/filepath"
"strings"
- "github.com/mediocregopher/blog.mediocregopher.com/srv/api/apiutil"
+ "github.com/mediocregopher/blog.mediocregopher.com/srv/http/apiutil"
"github.com/mediocregopher/blog.mediocregopher.com/srv/post"
"golang.org/x/image/draw"
)
diff --git a/srv/src/api/auth.go b/srv/src/http/auth.go
index 0d946a3..cd247a3 100644
--- a/srv/src/api/auth.go
+++ b/srv/src/http/auth.go
@@ -1,9 +1,9 @@
-package api
+package http
import (
"net/http"
- "github.com/mediocregopher/blog.mediocregopher.com/srv/api/apiutil"
+ "github.com/mediocregopher/blog.mediocregopher.com/srv/http/apiutil"
"golang.org/x/crypto/bcrypt"
)
diff --git a/srv/src/api/auth_test.go b/srv/src/http/auth_test.go
index cdf83ef..2a1e6e9 100644
--- a/srv/src/api/auth_test.go
+++ b/srv/src/http/auth_test.go
@@ -1,4 +1,4 @@
-package api
+package http
import (
"testing"
diff --git a/srv/src/api/chat.go b/srv/src/http/chat.go
index f4b90ef..f76e4ad 100644
--- a/srv/src/api/chat.go
+++ b/srv/src/http/chat.go
@@ -1,4 +1,4 @@
-package api
+package http
import (
"context"
@@ -9,8 +9,8 @@ import (
"unicode"
"github.com/gorilla/websocket"
- "github.com/mediocregopher/blog.mediocregopher.com/srv/api/apiutil"
"github.com/mediocregopher/blog.mediocregopher.com/srv/chat"
+ "github.com/mediocregopher/blog.mediocregopher.com/srv/http/apiutil"
)
type chatHandler struct {
diff --git a/srv/src/api/csrf.go b/srv/src/http/csrf.go
index 2a93ed7..1c80dee 100644
--- a/srv/src/api/csrf.go
+++ b/srv/src/http/csrf.go
@@ -1,10 +1,10 @@
-package api
+package http
import (
"errors"
"net/http"
- "github.com/mediocregopher/blog.mediocregopher.com/srv/api/apiutil"
+ "github.com/mediocregopher/blog.mediocregopher.com/srv/http/apiutil"
)
const (
diff --git a/srv/src/api/index.go b/srv/src/http/index.go
index 5fb5a4f..bb76568 100644
--- a/srv/src/api/index.go
+++ b/srv/src/http/index.go
@@ -1,4 +1,4 @@
-package api
+package http
import (
"fmt"
@@ -6,7 +6,7 @@ import (
"path/filepath"
"strings"
- "github.com/mediocregopher/blog.mediocregopher.com/srv/api/apiutil"
+ "github.com/mediocregopher/blog.mediocregopher.com/srv/http/apiutil"
"github.com/mediocregopher/blog.mediocregopher.com/srv/post"
)
diff --git a/srv/src/api/mailinglist.go b/srv/src/http/mailinglist.go
index c12e75d..90e602c 100644
--- a/srv/src/api/mailinglist.go
+++ b/srv/src/http/mailinglist.go
@@ -1,11 +1,11 @@
-package api
+package http
import (
"errors"
"net/http"
"strings"
- "github.com/mediocregopher/blog.mediocregopher.com/srv/api/apiutil"
+ "github.com/mediocregopher/blog.mediocregopher.com/srv/http/apiutil"
"github.com/mediocregopher/blog.mediocregopher.com/srv/mailinglist"
)
diff --git a/srv/src/api/middleware.go b/srv/src/http/middleware.go
index 974889b..8299a71 100644
--- a/srv/src/api/middleware.go
+++ b/srv/src/http/middleware.go
@@ -1,11 +1,11 @@
-package api
+package http
import (
"net"
"net/http"
"time"
- "github.com/mediocregopher/blog.mediocregopher.com/srv/api/apiutil"
+ "github.com/mediocregopher/blog.mediocregopher.com/srv/http/apiutil"
"github.com/mediocregopher/mediocre-go-lib/v2/mctx"
"github.com/mediocregopher/mediocre-go-lib/v2/mlog"
)
diff --git a/srv/src/api/posts.go b/srv/src/http/posts.go
index ab11474..fd583ea 100644
--- a/srv/src/api/posts.go
+++ b/srv/src/http/posts.go
@@ -1,4 +1,4 @@
-package api
+package http
import (
"errors"
@@ -12,7 +12,7 @@ import (
"github.com/gomarkdown/markdown"
"github.com/gomarkdown/markdown/html"
"github.com/gomarkdown/markdown/parser"
- "github.com/mediocregopher/blog.mediocregopher.com/srv/api/apiutil"
+ "github.com/mediocregopher/blog.mediocregopher.com/srv/http/apiutil"
"github.com/mediocregopher/blog.mediocregopher.com/srv/post"
)
diff --git a/srv/src/api/pow.go b/srv/src/http/pow.go
index ae2d2f1..1bd5cb5 100644
--- a/srv/src/api/pow.go
+++ b/srv/src/http/pow.go
@@ -1,4 +1,4 @@
-package api
+package http
import (
"encoding/hex"
@@ -6,7 +6,7 @@ import (
"fmt"
"net/http"
- "github.com/mediocregopher/blog.mediocregopher.com/srv/api/apiutil"
+ "github.com/mediocregopher/blog.mediocregopher.com/srv/http/apiutil"
)
func (a *api) newPowChallengeHandler() http.Handler {
diff --git a/srv/src/api/tpl.go b/srv/src/http/tpl.go
index 9818b10..d647317 100644
--- a/srv/src/api/tpl.go
+++ b/srv/src/http/tpl.go
@@ -1,4 +1,4 @@
-package api
+package http
import (
"embed"
@@ -10,7 +10,7 @@ import (
"strings"
"time"
- "github.com/mediocregopher/blog.mediocregopher.com/srv/api/apiutil"
+ "github.com/mediocregopher/blog.mediocregopher.com/srv/http/apiutil"
)
//go:embed tpl
diff --git a/srv/src/api/tpl/assets.html b/srv/src/http/tpl/assets.html
index aa5e422..aa5e422 100644
--- a/srv/src/api/tpl/assets.html
+++ b/srv/src/http/tpl/assets.html
diff --git a/srv/src/api/tpl/base.html b/srv/src/http/tpl/base.html
index 6031919..6031919 100644
--- a/srv/src/api/tpl/base.html
+++ b/srv/src/http/tpl/base.html
diff --git a/srv/src/api/tpl/edit-post.html b/srv/src/http/tpl/edit-post.html
index 9ccfa2a..9ccfa2a 100644
--- a/srv/src/api/tpl/edit-post.html
+++ b/srv/src/http/tpl/edit-post.html
diff --git a/srv/src/api/tpl/follow.html b/srv/src/http/tpl/follow.html
index 8cf9dc6..8cf9dc6 100644
--- a/srv/src/api/tpl/follow.html
+++ b/srv/src/http/tpl/follow.html
diff --git a/srv/src/api/tpl/index.html b/srv/src/http/tpl/index.html
index e27cbef..e27cbef 100644
--- a/srv/src/api/tpl/index.html
+++ b/srv/src/http/tpl/index.html
diff --git a/srv/src/api/tpl/post.html b/srv/src/http/tpl/post.html
index 474d7c2..474d7c2 100644
--- a/srv/src/api/tpl/post.html
+++ b/srv/src/http/tpl/post.html
diff --git a/srv/src/api/tpl/posts.html b/srv/src/http/tpl/posts.html
index 714cf07..714cf07 100644
--- a/srv/src/api/tpl/posts.html
+++ b/srv/src/http/tpl/posts.html
diff --git a/srv/src/api/tpl/redirect.html b/srv/src/http/tpl/redirect.html
index ed12a2e..ed12a2e 100644
--- a/srv/src/api/tpl/redirect.html
+++ b/srv/src/http/tpl/redirect.html