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/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/gui git.wit.org/gui/gui
go.wit.com/gui/widget git.wit.org/gui/widget go.wit.com/gui/widget git.wit.org/gui/widget
go.wit.com/gui/toolkits git.wit.org/gui/toolkits go.wit.com/gui/toolkits git.wit.org/gui/toolkits

View File

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

View File

@ -5,6 +5,7 @@ import (
"strings" "strings"
"go.wit.com/log" "go.wit.com/log"
"net/http" "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() { func readconfigfile() {
repoMap = make(map[string]string)
pfile, err := htmlFiles.ReadFile("files/repomap") pfile, err := htmlFiles.ReadFile("files/repomap")
if err != nil { if err != nil {
log.Error(err, "missing repomap in the binary") log.Error(err, "missing repomap in the binary")
@ -62,6 +76,21 @@ func readconfigfile() {
} }
repo := fields[0] repo := fields[0]
realurl := fields[1] 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])
} }
} }