Monorepo for Tangled tangled.org

appview: use https if s.config.Dev isn't set

Changed files
+35 -8
appview
state
+35 -8
appview/state/repo.go
··· 35 35 log.Println("failed to fully resolve repo", err) 36 36 return 37 37 } 38 + protocol := "http" 39 + if !s.config.Dev { 40 + protocol = "https" 41 + } 42 + 38 43 var reqUrl string 39 44 if ref != "" { 40 - reqUrl = fmt.Sprintf("http://%s/%s/%s/tree/%s", f.Knot, f.OwnerDid(), f.RepoName, ref) 45 + reqUrl = fmt.Sprintf("%s://%s/%s/%s/tree/%s", protocol, f.Knot, f.OwnerDid(), f.RepoName, ref) 41 46 } else { 42 - reqUrl = fmt.Sprintf("http://%s/%s/%s", f.Knot, f.OwnerDid(), f.RepoName) 47 + reqUrl = fmt.Sprintf("%s://%s/%s/%s", protocol, f.Knot, f.OwnerDid(), f.RepoName) 43 48 } 44 49 45 50 resp, err := http.Get(reqUrl) ··· 101 106 } 102 107 103 108 ref := chi.URLParam(r, "ref") 104 - resp, err := http.Get(fmt.Sprintf("http://%s/%s/%s/log/%s?page=%d&per_page=30", f.Knot, f.OwnerDid(), f.RepoName, ref, page)) 109 + 110 + protocol := "http" 111 + if !s.config.Dev { 112 + protocol = "https" 113 + } 114 + 115 + resp, err := http.Get(fmt.Sprintf("%s://%s/%s/%s/log/%s?page=%d&per_page=30", protocol, f.Knot, f.OwnerDid(), f.RepoName, ref, page)) 105 116 if err != nil { 106 117 log.Println("failed to reach knotserver", err) 107 118 return ··· 229 240 log.Println("failed to fully resolve repo", err) 230 241 return 231 242 } 232 - 233 243 ref := chi.URLParam(r, "ref") 234 - resp, err := http.Get(fmt.Sprintf("http://%s/%s/%s/commit/%s", f.Knot, f.OwnerDid(), f.RepoName, ref)) 244 + protocol := "http" 245 + if !s.config.Dev { 246 + protocol = "https" 247 + } 248 + resp, err := http.Get(fmt.Sprintf("%s://%s/%s/%s/commit/%s", protocol, f.Knot, f.OwnerDid(), f.RepoName, ref)) 235 249 if err != nil { 236 250 log.Println("failed to reach knotserver", err) 237 251 return ··· 268 282 269 283 ref := chi.URLParam(r, "ref") 270 284 treePath := chi.URLParam(r, "*") 271 - resp, err := http.Get(fmt.Sprintf("http://%s/%s/%s/tree/%s/%s", f.Knot, f.OwnerDid(), f.RepoName, ref, treePath)) 285 + protocol := "http" 286 + if !s.config.Dev { 287 + protocol = "https" 288 + } 289 + resp, err := http.Get(fmt.Sprintf("%s://%s/%s/%s/tree/%s/%s", protocol, f.Knot, f.OwnerDid(), f.RepoName, ref, treePath)) 272 290 if err != nil { 273 291 log.Println("failed to reach knotserver", err) 274 292 return ··· 318 336 return 319 337 } 320 338 321 - resp, err := http.Get(fmt.Sprintf("http://%s/%s/%s/tags", f.Knot, f.OwnerDid(), f.RepoName)) 339 + protocol := "http" 340 + if !s.config.Dev { 341 + protocol = "https" 342 + } 343 + 344 + resp, err := http.Get(fmt.Sprintf("%s://%s/%s/%s/tags", protocol, f.Knot, f.OwnerDid(), f.RepoName)) 322 345 if err != nil { 323 346 log.Println("failed to reach knotserver", err) 324 347 return ··· 390 413 391 414 ref := chi.URLParam(r, "ref") 392 415 filePath := chi.URLParam(r, "*") 393 - resp, err := http.Get(fmt.Sprintf("http://%s/%s/%s/blob/%s/%s", f.Knot, f.OwnerDid(), f.RepoName, ref, filePath)) 416 + protocol := "http" 417 + if !s.config.Dev { 418 + protocol = "https" 419 + } 420 + resp, err := http.Get(fmt.Sprintf("%s://%s/%s/%s/blob/%s/%s", protocol, f.Knot, f.OwnerDid(), f.RepoName, ref, filePath)) 394 421 if err != nil { 395 422 log.Println("failed to reach knotserver", err) 396 423 return