forked from tangled.org/core
Monorepo for Tangled

appview/config: add TANGLED_DEV config

anirudh.fi 6d117f8c 74ac77e6

verified
Changed files
+12 -4
appview
+1
appview/config.go
··· 10 10 CookieSecret string `env:"TANGLED_COOKIE_SECRET, default=00000000000000000000000000000000"` 11 11 DbPath string `env:"TANGLED_DB_PATH, default=appview.db"` 12 12 ListenAddr string `env:"TANGLED_LISTEN_ADDR, default=0.0.0.0:3000"` 13 + Dev bool `env:"TANGLED_DEV, default=false"` 13 14 } 14 15 15 16 func LoadConfig(ctx context.Context) (*Config, error) {
+5 -3
appview/state/git_http.go
··· 14 14 knot := r.Context().Value("knot").(string) 15 15 repo := chi.URLParam(r, "repo") 16 16 17 - // TODO: make this https for production! 18 - targetURL := fmt.Sprintf("https://%s/%s/%s/info/refs?%s", knot, user.DID, repo, r.URL.RawQuery) 17 + uri := "https" 18 + if s.config.Dev { 19 + uri = "http" 20 + } 21 + targetURL := fmt.Sprintf("%s://%s/%s/%s/info/refs?%s", uri, knot, user.DID, repo, r.URL.RawQuery) 19 22 resp, err := http.Get(targetURL) 20 23 if err != nil { 21 24 http.Error(w, err.Error(), http.StatusInternalServerError) ··· 47 50 } 48 51 knot := r.Context().Value("knot").(string) 49 52 repo := chi.URLParam(r, "repo") 50 - // TODO: make this https for production! 51 53 targetURL := fmt.Sprintf("https://%s/%s/%s/git-upload-pack?%s", knot, user.DID, repo, r.URL.RawQuery) 52 54 client := &http.Client{} 53 55
+6 -1
appview/state/signer.go
··· 9 9 "fmt" 10 10 "net/http" 11 11 "net/url" 12 + "os" 12 13 "time" 13 14 ) 14 15 ··· 41 42 }, 42 43 } 43 44 44 - url, err := url.Parse(fmt.Sprintf("https://%s", domain)) 45 + uri := "https" 46 + if os.Getenv("TANGLED_DEV") == "true" { 47 + uri = "http" 48 + } 49 + url, err := url.Parse(fmt.Sprintf("%s://%s", uri, domain)) 45 50 if err != nil { 46 51 return nil, err 47 52 }