From 09acb111a2b22f5794541fac175b024dd0f9100e Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Fri, 20 May 2022 11:17:31 -0600 Subject: Rename api package to http --- srv/src/cmd/hash-password/main.go | 4 ++-- srv/src/cmd/mediocre-blog/main.go | 42 +++++++++++++++++++-------------------- 2 files changed, 23 insertions(+), 23 deletions(-) (limited to 'srv/src/cmd') 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) } }() -- cgit v1.2.3