diff --git a/base/nfs/cat.go b/base/nfs/cat.go index 06b934e3..2fce13ad 100644 --- a/base/nfs/cat.go +++ b/base/nfs/cat.go @@ -141,6 +141,9 @@ func Template(m templateMessage, p string, arg ...ice.Any) string { func TemplateText(m templateMessage, p string) string { return m.Cmdx(CAT, path.Join(m.PrefixKey(), path.Base(p)), kit.Dict(DIR_ROOT, ice.SRC_TEMPLATE)) } +func TemplatePath(m templateMessage, arg ...string) string { + return path.Join(ice.SRC_TEMPLATE, m.PrefixKey(), path.Join(arg...)) +} func IsSourceFile(m *ice.Message, ext string) bool { return mdb.Conf(m, Prefix(CAT), kit.Keym(SOURCE, ext)) == ice.TRUE } diff --git a/base/web/serve.go b/base/web/serve.go index a211f3e4..0457b20f 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -108,7 +108,10 @@ func _serve_handle(key string, cmd *ice.Command, m *ice.Message, w http.Response kit.If(m.Optionv(ice.MSG_CMDS) == nil, func() { kit.If(strings.TrimPrefix(r.URL.Path, key), func(p string) { m.Optionv(ice.MSG_CMDS, strings.Split(p, nfs.PS)) }) }) - defer func() { Render(m, m.Option(ice.MSG_OUTPUT), kit.List(m.Optionv(ice.MSG_ARGS))...) }() + defer func() { + Render(m, m.Option(ice.MSG_OUTPUT), kit.List(m.Optionv(ice.MSG_ARGS))...) + m.Debug("what %v", m.FormatMeta()) + }() if cmds, ok := _serve_auth(m, key, kit.Simple(m.Optionv(ice.MSG_CMDS)), w, r); ok { defer func() { m.Cost(kit.Format("%s: %s %v", r.Method, m.PrefixPath()+path.Join(cmds...), m.FormatSize())) }() m.Option(ice.MSG_OPTS, kit.Simple(m.Optionv(ice.MSG_OPTION), func(k string) bool { return !strings.HasPrefix(k, ice.MSG_SESSID) })) diff --git a/base/web/spide.go b/base/web/spide.go index 446079bd..cb0207ab 100644 --- a/base/web/spide.go +++ b/base/web/spide.go @@ -53,12 +53,23 @@ func _spide_show(m *ice.Message, name string, arg ...string) { return } defer res.Body.Close() + m.Push(mdb.TYPE, "status") + m.Push(mdb.NAME, res.StatusCode) + m.Push(mdb.VALUE, res.Status) m.Cost(cli.STATUS, res.Status, nfs.SIZE, kit.FmtSize(kit.Int64(res.Header.Get(ContentLength))), mdb.TYPE, res.Header.Get(ContentType)) - kit.For(res.Header, func(k string, v []string) { m.Logs("response", k, v) }) + kit.For(res.Header, func(k string, v []string) { + m.Logs("response", k, v) + m.Push(mdb.TYPE, "header") + m.Push(mdb.NAME, k) + m.Push(mdb.VALUE, v[0]) + }) mdb.HashSelectUpdate(m, name, func(value ice.Map) { kit.For(res.Cookies(), func(v *http.Cookie) { kit.Value(value, kit.Keys(SPIDE_COOKIE, v.Name), v.Value) m.Logs("response", v.Name, v.Value) + m.Push(mdb.TYPE, "cookie") + m.Push(mdb.NAME, v.Name) + m.Push(mdb.VALUE, v.Value) }) }) if m.Warn(res.StatusCode != http.StatusOK && res.StatusCode != http.StatusCreated, ice.ErrNotValid, uri, cli.STATUS, res.Status) { @@ -168,9 +179,13 @@ func _spide_send(m *ice.Message, name string, req *http.Request, timeout string) return client.Do(req) } func _spide_save(m *ice.Message, action, file, uri string, res *http.Response) { + if action == SPIDE_RAW { + m.SetResult() + } else { + m.SetAppend().SetResult() + } switch action { case SPIDE_RAW: - m.SetResult() if b, _ := ioutil.ReadAll(res.Body); strings.HasPrefix(res.Header.Get(ContentType), ApplicationJSON) { m.Echo(kit.Formats(kit.UnMarshal(string(b)))) } else {