Browse Source

syntax highlighting for xml/html content

Alan Shreve 12 years ago
parent
commit
5e1863e411
2 changed files with 15 additions and 2 deletions
  1. 1 1
      assets/body.html
  2. 14 1
      src/ngrok/client/views/web/http.go

+ 1 - 1
assets/body.html

@@ -27,7 +27,7 @@
 
 
 {{ with handleOther .BodyBytes .Header }}
-<pre><code>{{ .}}</code></pre>
+<pre><code class="{{.Syntax}}">{{.Body}}</code></pre>
 {{ end }}
 
 {{ end }}

+ 14 - 1
src/ngrok/client/views/web/http.go

@@ -154,7 +154,20 @@ func (h *WebHttpView) register() {
 					return nil
 				}
 
-				return string(b)
+				syntaxMap := map[string]string{
+					"text/xml":        "xml",
+					"application/xml": "xml",
+					"text/html":       "xml",
+				}
+
+				ctype := strings.Split(h.Get("Content-Type"), ";")[0]
+				return struct {
+					Body   string
+					Syntax string
+				}{
+					string(b),
+					syntaxMap[strings.TrimSpace(ctype)],
+				}
 			},
 		}