mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 01:04:06 +08:00
add web.time.cost
This commit is contained in:
parent
668dacb7c5
commit
a19e759ec9
@ -4,5 +4,5 @@ var version = struct {
|
|||||||
host string
|
host string
|
||||||
self int
|
self int
|
||||||
}{
|
}{
|
||||||
"2019-08-06 21:00:10", "ZYB-20190522USI", 379,
|
"2019-08-13 16:01:31", "ZYB-20190522USI", 382,
|
||||||
}
|
}
|
||||||
|
@ -90,8 +90,13 @@ type DEBUG interface {
|
|||||||
func (m *Message) Time(arg ...interface{}) string {
|
func (m *Message) Time(arg ...interface{}) string {
|
||||||
t := m.time
|
t := m.time
|
||||||
if len(arg) > 0 {
|
if len(arg) > 0 {
|
||||||
if d, e := time.ParseDuration(arg[0].(string)); e == nil {
|
switch v := arg[0].(type) {
|
||||||
arg, t = arg[1:], t.Add(d)
|
case time.Time:
|
||||||
|
return fmt.Sprintf("%v", v.Sub(t))
|
||||||
|
default:
|
||||||
|
if d, e := time.ParseDuration(arg[0].(string)); e == nil {
|
||||||
|
arg, t = arg[1:], t.Add(d)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MUX interface {
|
type MUX interface {
|
||||||
@ -158,6 +159,9 @@ func (web *WEB) Login(msg *ctx.Message, w http.ResponseWriter, r *http.Request)
|
|||||||
func (web *WEB) HandleCmd(m *ctx.Message, key string, cmd *ctx.Command) {
|
func (web *WEB) HandleCmd(m *ctx.Message, key string, cmd *ctx.Command) {
|
||||||
web.HandleFunc(key, func(w http.ResponseWriter, r *http.Request) {
|
web.HandleFunc(key, func(w http.ResponseWriter, r *http.Request) {
|
||||||
m.TryCatch(m.Spawn(m.Conf("serve", "autofree")), true, func(msg *ctx.Message) {
|
m.TryCatch(m.Spawn(m.Conf("serve", "autofree")), true, func(msg *ctx.Message) {
|
||||||
|
defer func() {
|
||||||
|
msg.Log("time", "cost: %v", msg.Time(time.Now()))
|
||||||
|
}()
|
||||||
msg.Option("remote_addr", r.RemoteAddr)
|
msg.Option("remote_addr", r.RemoteAddr)
|
||||||
msg.Option("remote_ip", r.Header.Get("remote_ip"))
|
msg.Option("remote_ip", r.Header.Get("remote_ip"))
|
||||||
msg.Option("index_url", r.Header.Get("index_url"))
|
msg.Option("index_url", r.Header.Get("index_url"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user