1
0
forked from x/icebergs
This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-12-12 21:42:39 +08:00
parent b54e6b0a01
commit 37d2d84381
3 changed files with 19 additions and 1 deletions

View File

@ -95,7 +95,7 @@ func _serve_static(msg *ice.Message, w http.ResponseWriter, r *http.Request) boo
}
func _serve_handle(key string, cmd *ice.Command, m *ice.Message, w http.ResponseWriter, r *http.Request) {
debug := strings.Contains(r.URL.String(), "debug=true") || strings.Contains(r.Header.Get(html.Referer), "debug=true")
m.Options(ice.LOG_TRACEID, r.Header.Get(ice.LOG_TRACEID), ice.MSG_LANGUAGE, "")
m.Options(ice.LOG_TRACEID, r.Header.Get(ice.LOG_TRACEID))
_log := func(level string, arg ...ice.Any) *ice.Message {
if debug || arg[0] == ice.MSG_CMDS {
return m.Logs(strings.Title(level), arg...)
@ -167,6 +167,11 @@ func _serve_domain(m *ice.Message) string {
}
func _serve_auth(m *ice.Message, key string, cmds []string, w http.ResponseWriter, r *http.Request) ([]string, bool) {
kit.If(len(cmds) > 0, func() { cmds = append(kit.Split(cmds[0], ","), cmds[1:]...) })
defer func() {
kit.For(m.Optionv(""), func(key string) {
kit.If(strings.HasPrefix(key, ice.MSG_SESSID), func() { m.Set(ice.MSG_OPTION, key) })
})
}()
if r.URL.Path == PP(SPACE) {
aaa.SessCheck(m, m.Option(ice.MSG_SESSID))
return cmds, true

View File

@ -29,6 +29,7 @@ func (f *Frame) Begin(m *ice.Message, arg ...string) {}
func (f *Frame) Start(m *ice.Message, arg ...string) {
f.Message, f.Server = m, &http.Server{Handler: f}
list := map[*ice.Context]string{}
m.Options(ice.MSG_LANGUAGE, "")
m.Travel(func(p *ice.Context, c *ice.Context) {
f, ok := c.Server().(*Frame)
if !ok || f.ServeMux != nil {

12
meta.go
View File

@ -21,6 +21,18 @@ func (m *Message) Set(key string, arg ...string) *Message {
} else if len(arg) > 0 {
if m.delete(arg[0]); len(arg) > 1 {
m.value(arg[0], arg[1:]...)
} else {
list := m.value(key)
for i, k := range list {
if k == arg[0] {
for ; i < len(list)-1; i++ {
list[i] = list[i+1]
}
list = list[:len(list)-1]
m.value(key, list...)
break
}
}
}
} else {
kit.For(m.value(key), func(k string) { m.delete(k) })