// +build httpstats package go9p import ( "fmt" "io" "net/http" ) func (clnt *Clnt) ServeHTTP(c http.ResponseWriter, r *http.Request) { io.WriteString(c, fmt.Sprintf("

Client %s

", clnt.Id)) defer io.WriteString(c, "") // fcalls if clnt.Debuglevel&DbgLogFcalls != 0 { fs := clnt.Log.Filter(clnt, DbgLogFcalls) io.WriteString(c, fmt.Sprintf("

Last %d 9P messages

", len(fs))) for _, l := range fs { fc := l.Data.(*Fcall) if fc.Type != 0 { io.WriteString(c, fmt.Sprintf("
%s", fc)) } } } } func clntServeHTTP(c http.ResponseWriter, r *http.Request) { io.WriteString(c, fmt.Sprintf("")) defer io.WriteString(c, "") clnts.Lock() if clnts.clntList == nil { io.WriteString(c, "no clients") } for clnt := clnts.clntList; clnt != nil; clnt = clnt.next { io.WriteString(c, fmt.Sprintf("%s
", clnt.Id, clnt.Id)) } clnts.Unlock() } func (clnt *Clnt) statsRegister() { http.Handle("/go9p/clnt/"+clnt.Id, clnt) } func (clnt *Clnt) statsUnregister() { http.Handle("/go9p/clnt/"+clnt.Id, nil) } func (c *ClntList) statsRegister() { http.HandleFunc("/go9p/clnt", clntServeHTTP) } func (c *ClntList) statsUnregister() { http.HandleFunc("/go9p/clnt", nil) }