mirror of
https://shylinux.com/x/icebergs
synced 2025-04-28 18:22:02 +08:00
opt url
This commit is contained in:
parent
5b9fce5dc6
commit
40628e005a
@ -84,6 +84,10 @@ func _serve_main(m *ice.Message, w http.ResponseWriter, r *http.Request) bool {
|
|||||||
case func(w http.ResponseWriter, r *http.Request) func():
|
case func(w http.ResponseWriter, r *http.Request) func():
|
||||||
defer h(w, r)
|
defer h(w, r)
|
||||||
|
|
||||||
|
case func(p string, w http.ResponseWriter, r *http.Request) bool:
|
||||||
|
if h(r.URL.Path, w, r) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
case func(w http.ResponseWriter, r *http.Request) bool:
|
case func(w http.ResponseWriter, r *http.Request) bool:
|
||||||
if h(w, r) {
|
if h(w, r) {
|
||||||
return false
|
return false
|
||||||
|
@ -119,19 +119,20 @@ func init() {
|
|||||||
}},
|
}},
|
||||||
"/repos/": {Name: "/repos/", Help: "代码库", Action: ice.MergeAction(map[string]*ice.Action{
|
"/repos/": {Name: "/repos/", Help: "代码库", Action: ice.MergeAction(map[string]*ice.Action{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
web.AddRewrite(func(w http.ResponseWriter, r *http.Request) bool {
|
web.AddRewrite(func(p string, w http.ResponseWriter, r *http.Request) bool {
|
||||||
if p := r.URL.Path; strings.HasPrefix(p, "/x/") {
|
if strings.HasPrefix(p, "/chat/pod/") {
|
||||||
if ls := strings.Split(p, ice.PS); m.Cmd(web.DREAM, ls[2]).Length() > 0 {
|
if strings.HasPrefix(r.Header.Get("User-Agent"), "git") || strings.HasPrefix(r.Header.Get("User-Agent"), "Go") {
|
||||||
if m.IsCliUA() {
|
r.URL.Path = strings.Replace(r.URL.Path, "/chat/pod/", "/code/git/repos/", 1)
|
||||||
r.URL.RawQuery += kit.Select("", "&", len(r.URL.RawQuery) > 1) + "pod=" + ls[2]
|
m.Info("rewrite %v -> %v", p, r.URL.Path)
|
||||||
r.URL.Path = "/share/local/bin/ice.bin"
|
} else if strings.HasPrefix(r.Header.Get("User-Agent"), "curl") || strings.HasPrefix(r.Header.Get("User-Agent"), "Wget") {
|
||||||
} else {
|
if ls := strings.Split(p, ice.PS); m.Cmd(web.DREAM, ls[3]).Length() > 0 {
|
||||||
r.URL.Path = strings.Replace(r.URL.Path, "/x/", "/chat/pod/", 1)
|
r.URL.RawQuery += kit.Select("", "&", len(r.URL.RawQuery) > 1) + "pod=" + ls[3]
|
||||||
}
|
}
|
||||||
} else {
|
r.URL.Path = "/share/local/bin/ice.bin"
|
||||||
r.URL.Path = strings.Replace(r.URL.Path, "/x/", "/code/git/repos/", 1)
|
m.Info("rewrite %v -> %v", p, r.URL.Path)
|
||||||
}
|
}
|
||||||
|
} else if strings.HasPrefix(p, "/x/") {
|
||||||
|
r.URL.Path = strings.Replace(r.URL.Path, "/x/", "/code/git/repos/", 1)
|
||||||
m.Info("rewrite %v -> %v", p, r.URL.Path)
|
m.Info("rewrite %v -> %v", p, r.URL.Path)
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user