// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package geerpc import ( "fmt" "html/template" "net/http" ) const debugText = ` GeeRPC Services {{range .}}
Service {{.Name}}
{{range $name, $mtype := .Method}} {{end}}
MethodCalls
{{$name}}({{$mtype.ArgType}}, {{$mtype.ReplyType}}) error {{$mtype.NumCalls}}
{{end}} ` var debug = template.Must(template.New("RPC debug").Parse(debugText)) type debugHTTP struct { *Server } type debugService struct { Name string Method map[string]*methodType } // Runs at /debug/geerpc func (server debugHTTP) ServeHTTP(w http.ResponseWriter, req *http.Request) { // Build a sorted version of the data. var services []debugService server.serviceMap.Range(func(namei, svci interface{}) bool { svc := svci.(*service) services = append(services, debugService{ Name: namei.(string), Method: svc.method, }) return true }) err := debug.Execute(w, services) if err != nil { _, _ = fmt.Fprintln(w, "rpc: error executing template:", err.Error()) } }