looks up repo url

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-12 11:13:26 -06:00
parent 0be507b896
commit 23fa94cbcd
3 changed files with 36 additions and 6 deletions

View File

@ -1,6 +1,6 @@
go.wit.com/log git.wit.org/wit/log
go.wit.com/gui git.wit.org/gui/
go.wit.com/gui git.wit.org/wit/gui-old/
go.wit.com/gui/gui git.wit.org/gui/gui
go.wit.com/gui/widget git.wit.org/gui/widget
go.wit.com/gui/toolkits git.wit.org/gui/toolkits

View File

@ -2,7 +2,7 @@ package main
import (
"fmt"
"log"
"go.wit.com/log"
"net/http"
"embed"
)
@ -14,12 +14,14 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
dumpClient(r)
var tmp string
tmp = r.URL.String()
url, repourl := findkey(tmp)
log.Info("url =", url, "repo url =", repourl)
if tmp == "/test" {
findFile(w)
// findFile(w)
return
}
if tmp == "/gui" {
doGui(w, "/gui/gui")
// doGui(w, "/gui/gui")
return
}
fmt.Fprintln(w, "OK")
@ -57,7 +59,6 @@ func main() {
}
*/
readconfigfile()
return
http.HandleFunc("/", okHandler)
err := http.ListenAndServe(":80", nil)
if err != nil {

View File

@ -5,6 +5,7 @@ import (
"strings"
"go.wit.com/log"
"net/http"
"sort"
)
@ -48,7 +49,20 @@ func doGui(w http.ResponseWriter, path string) {
*/
}
var repoMap map[string]string
var keysSorted []string
func findkey(url string) (string, string) {
key := "go.wit.com" + url
if repoMap[key] != "" {
return key, repoMap[key]
}
return key, ""
// parts := strings.Split(key, "/")
}
func readconfigfile() {
repoMap = make(map[string]string)
pfile, err := htmlFiles.ReadFile("files/repomap")
if err != nil {
log.Error(err, "missing repomap in the binary")
@ -62,6 +76,21 @@ func readconfigfile() {
}
repo := fields[0]
realurl := fields[1]
log.Info("repo =", repo, "real url =", realurl)
repoMap[repo] = realurl
// log.Info("repo =", repo, "real url =", realurl)
}
for repo, _ := range repoMap {
// log.Info("repo =", repo, "real url =", url)
keysSorted = append(keysSorted, repo)
}
log.Info("sorted:")
sort.Strings(keysSorted)
// sort.Reverse(keys)
sort.Sort(sort.Reverse(sort.StringSlice(keysSorted)))
for _, key := range keysSorted {
log.Info("repo =", key, "real url =", repoMap[key])
}
}