mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 17:24:05 +08:00
Merge branch 'master' of github.com:shylinux/context
This commit is contained in:
commit
d72d769efb
@ -1,7 +1,7 @@
|
|||||||
~stdio
|
~stdio
|
||||||
config load history.json history
|
config load history.json history
|
||||||
~web
|
~web
|
||||||
# config load web.json
|
config load web.json
|
||||||
|
|
||||||
~aaa
|
~aaa
|
||||||
login root root
|
login root root
|
||||||
|
@ -3057,7 +3057,7 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
|
|||||||
arg, all = arg[1:], true
|
arg, all = arg[1:], true
|
||||||
}
|
}
|
||||||
|
|
||||||
action, which := "", "-1"
|
action, which, chain := "", "-1", ""
|
||||||
have := map[string]bool{}
|
have := map[string]bool{}
|
||||||
if len(arg) > 0 {
|
if len(arg) > 0 {
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
@ -3073,6 +3073,8 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
|
|||||||
}
|
}
|
||||||
case "create", "delete":
|
case "create", "delete":
|
||||||
action, arg = arg[0], arg[1:]
|
action, arg = arg[0], arg[1:]
|
||||||
|
case "parse":
|
||||||
|
chain, arg = arg[1], arg[2:]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3156,7 +3158,7 @@ var Index = &Context{Name: "ctx", Help: "模块中心",
|
|||||||
|
|
||||||
msg := m.Spawn()
|
msg := m.Spawn()
|
||||||
msg.Put("option", "_cache", value)
|
msg.Put("option", "_cache", value)
|
||||||
msg.Cmd("trans", "_cache", "")
|
msg.Cmd("trans", "_cache", chain)
|
||||||
m.Copy(msg, "append").Copy(msg, "result")
|
m.Copy(msg, "append").Copy(msg, "result")
|
||||||
}},
|
}},
|
||||||
"cache": &Command{Name: "cache [all] |key [value]|key = value|key name value help|delete key]",
|
"cache": &Command{Name: "cache [all] |key [value]|key = value|key name value help|delete key]",
|
||||||
|
@ -434,9 +434,6 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
if m.Has("method") {
|
if m.Has("method") {
|
||||||
method = m.Option("method")
|
method = m.Option("method")
|
||||||
}
|
}
|
||||||
m.Log("fuck", "what %s", method)
|
|
||||||
m.Log("fuck", "what %s", m.Option("method"))
|
|
||||||
m.Log("fuck", "what %s", m.Conf("method"))
|
|
||||||
uri := Merge(m, arg[0], arg[1:]...)
|
uri := Merge(m, arg[0], arg[1:]...)
|
||||||
body, _ := m.Optionv("body").(io.Reader)
|
body, _ := m.Optionv("body").(io.Reader)
|
||||||
|
|
||||||
@ -446,7 +443,6 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m.Log("fuck", "what %s", method)
|
|
||||||
req, e := http.NewRequest(method, uri, body)
|
req, e := http.NewRequest(method, uri, body)
|
||||||
m.Assert(e)
|
m.Assert(e)
|
||||||
|
|
||||||
@ -515,6 +511,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
}
|
}
|
||||||
|
|
||||||
ct := res.Header.Get("Content-Type")
|
ct := res.Header.Get("Content-Type")
|
||||||
|
m.Log("info", "content: %s", ct)
|
||||||
switch {
|
switch {
|
||||||
case strings.HasPrefix(ct, "application/json"):
|
case strings.HasPrefix(ct, "application/json"):
|
||||||
json.NewDecoder(res.Body).Decode(&result)
|
json.NewDecoder(res.Body).Decode(&result)
|
||||||
@ -558,6 +555,19 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
m.Add("append", "html", html)
|
m.Add("append", "html", html)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
case strings.HasPrefix(ct, "text"):
|
||||||
|
buf, e := ioutil.ReadAll(res.Body)
|
||||||
|
m.Assert(e)
|
||||||
|
if m.Has("parse") {
|
||||||
|
json.Unmarshal(buf, &result)
|
||||||
|
m.Log("fuck", "%v ", result)
|
||||||
|
msg := m.Spawn()
|
||||||
|
msg.Put("option", "response", result)
|
||||||
|
msg.Cmd("trans", "response", m.Option("parse"))
|
||||||
|
m.Copy(msg, "append").Copy(msg, "result")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
result = string(buf)
|
||||||
default:
|
default:
|
||||||
if w, ok := m.Optionv("response").(http.ResponseWriter); ok {
|
if w, ok := m.Optionv("response").(http.ResponseWriter); ok {
|
||||||
header := w.Header()
|
header := w.Header()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user