Pass the context from app to locale.mustGetAvailableLanguages
There is no reason for that function to know the context.
This commit is contained in:
parent
dd0a4a8ba9
commit
ca4ecd3a3e
|
@ -6,6 +6,7 @@
|
|||
package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"golang.org/x/text/language"
|
||||
|
@ -28,7 +29,7 @@ type App struct {
|
|||
}
|
||||
|
||||
func New(db *database.DB, avatarsDir string) (http.Handler, error) {
|
||||
locales := locale.MustGetAll(db)
|
||||
locales := locale.MustGetAll(context.Background(), db)
|
||||
static := http.FileServer(http.Dir("web/static"))
|
||||
profile, err := newProfileHandler(static, avatarsDir)
|
||||
if err != nil {
|
||||
|
|
|
@ -31,8 +31,8 @@ func (m Locales) Tags() []language.Tag {
|
|||
return keys
|
||||
}
|
||||
|
||||
func MustGetAll(db *database.DB) Locales {
|
||||
availableLanguages := mustGetAvailableLanguages(db)
|
||||
func MustGetAll(ctx context.Context, db *database.DB) Locales {
|
||||
availableLanguages := mustGetAvailableLanguages(ctx, db)
|
||||
locales := map[language.Tag]*Locale{}
|
||||
for _, lang := range availableLanguages {
|
||||
locale := newLocale(lang)
|
||||
|
@ -85,8 +85,8 @@ type availableLanguage struct {
|
|||
currencyPattern string
|
||||
}
|
||||
|
||||
func mustGetAvailableLanguages(db *database.DB) []availableLanguage {
|
||||
rows, err := db.Query(context.Background(), "select lang_tag, currency_pattern from language where selectable")
|
||||
func mustGetAvailableLanguages(ctx context.Context, db *database.DB) []availableLanguage {
|
||||
rows, err := db.Query(ctx, "select lang_tag, currency_pattern from language where selectable")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue