summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--files/repomap2
-rw-r--r--main.go9
-rw-r--r--repoHTML.go31
3 files changed, 36 insertions, 6 deletions
diff --git a/files/repomap b/files/repomap
index fc0d379..1fd1ccc 100644
--- a/files/repomap
+++ b/files/repomap
@@ -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
diff --git a/main.go b/main.go
index 609a267..120d759 100644
--- a/main.go
+++ b/main.go
@@ -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 {
diff --git a/repoHTML.go b/repoHTML.go
index 26ecd46..f33bb71 100644
--- a/repoHTML.go
+++ b/repoHTML.go
@@ -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])
}
}