(rw http.ResponseWriter, req *http.Request)
| 137 | } |
| 138 | |
| 139 | func (hh *HelpHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) { |
| 140 | suffix := httputil.PathSuffix(req) |
| 141 | if !httputil.IsGet(req) { |
| 142 | http.Error(rw, "Illegal help method.", http.StatusMethodNotAllowed) |
| 143 | return |
| 144 | } |
| 145 | switch suffix { |
| 146 | case "": |
| 147 | cc, err := fixServerInConfig(hh.clientConfig, req) |
| 148 | if err != nil { |
| 149 | httputil.ServeError(rw, req, err) |
| 150 | return |
| 151 | } |
| 152 | if clientConfig := req.FormValue("clientConfig"); clientConfig != "" { |
| 153 | if clientConfigOnly, err := strconv.ParseBool(clientConfig); err == nil && clientConfigOnly { |
| 154 | httputil.ReturnJSON(rw, cc) |
| 155 | return |
| 156 | } |
| 157 | } |
| 158 | hh.serveHelpHTML(cc, rw, req) |
| 159 | default: |
| 160 | http.Error(rw, "Illegal help path.", http.StatusNotFound) |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | func (hh *HelpHandler) serveHelpHTML(cc *clientconfig.Config, rw http.ResponseWriter, req *http.Request) { |
| 165 | jsonBytes, err := json.MarshalIndent(cc, "", " ") |
nothing calls this directly
no test coverage detected