1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
| {% import ( "fmt" "strings"
"{{{ .Package }}}/app/controller/cutil" "{{{ .Package }}}/app/lib/har" "{{{ .Package }}}/app/util" ) %}
{% func RenderRequest(key string, r *har.Request, ps *cutil.PageState) %} <div class="overflow full-width"> <table class="min-200 expanded"> <tbody> <tr> <th class="shrink">Method</th> <td>{%s r.Method %}</td> </tr> <tr> <th class="shrink">URL</th> <td><a target="_blank" rel="noopener noreferrer" href="{%s r.URL %}">{%s r.URL %}</a></td> </tr> <tr> <th class="shrink">Headers </th> <td>{%= renderNVPsHidden(fmt.Sprintf("request-header-%s", key), "Header", r.Headers, r.HeadersSize, ps) %}</td> </tr> {%- if len(r.QueryString) > 0 -%} <tr> <th class="shrink">Query String</th> <td>{%= renderNVPsHidden(fmt.Sprintf("request-query-string-%s", key), "Query String", r.QueryString, 0, ps) %}</td> </tr> {%- endif -%} {%- if len(r.Cookies) > 0 -%} <tr> <th class="shrink">Cookies</th> <td>{%= renderCookiesHidden(fmt.Sprintf("request-cookies-%s", key), r.Cookies, ps) %}</td> </tr> {%- endif -%} {%- if r.PostData != nil -%} <tr> <th class="shrink">Body</th> <td> <div class="right"><em>{% if r.PostData.MimeType != "" %}{%s r.PostData.MimeType %}, {% endif %}{%s util.ByteSizeSI(int64(r.BodySize)) %}</em></div> {%- if len(r.PostData.Params) > 0 -%} <ul> {%- for _, param := range r.PostData.Params -%} <li><strong>{%s param.Name %}</strong>: {%s param.Value %}</li> {%- endfor -%} </ul> {%- elseif r.PostData.Text != "" -%} <ul class="accordion"> <li> <input id="accordion-request-body-{%s key %}" type="checkbox" hidden /> <label class="no-padding" for="accordion-request-body-{%s key %}"><em>(click to show)</em></label> <div class="bd"><div><div> <pre>{%s r.PostData.Text %}</pre> </div></div></div> </li> </ul> {%- endif -%} </td> </tr> {%- endif -%} </tbody> </table> </div> {% endfunc %}
{% func renderCookiesHidden(key string, cookies har.Cookies, ps *cutil.PageState) %} <ul class="accordion"> <li> <input id="accordion-cookies-{%s key %}" type="checkbox" hidden /> <label class="no-padding" for="accordion-cookies-{%s key %}">{%s util.StringPlural(len(cookies), "Cookie") %} <em>(click to show)</em></label> <div class="bd"><div><div> {%= renderCookies(key, cookies, ps) %} </div></div></div> </li> </ul> {% endfunc %}
{% func renderCookies(key string, cs har.Cookies, ps *cutil.PageState) %} <div class="overflow full-width"> <table> <thead> <tr> <th class="shrink">Name</th> <th class="shrink">Value</th> <th class="shrink">Path</th> <th class="shrink">Domain</th> <th class="shrink">Expires</th> <th>Tags</th> </tr> </thead> <tbody> {%- for i, c := range cs -%} <tr> <td>{%s c.Name %}</td> <td> {%- if len(c.Value) > 64 -%} <ul class="accordion"> <li> <input id="accordion-{%s key %}-cookie-{%d i %}" type="checkbox" hidden /> <label class="no-padding" for="accordion-{%s key %}-cookie-{%d i %}">{%s c.Value[:64] %}...</label> <div class="bd"><div><div> {%s c.Value %} </div></div></div> </li> </ul> {%- else -%} {%s c.Value %} {%- endif -%} </td> <td>{%s c.Path %}</td> <td>{%s c.Domain %}</td> <td title="{%s util.TimeToFull(c.Exp()) %}">{%s c.ExpRelative() %}</td> <td>{%s strings.Join(c.Tags(), ", ") %}</td> </tr> {%- endfor -%} </tbody> </table> </div> {% endfunc %}
{% func renderNVPsHidden(key string, title string, nvps har.NVPs, size int, ps *cutil.PageState) %} <ul class="accordion"> <li> <input id="accordion-{%s key %}" type="checkbox" hidden /> <label class="no-padding" for="accordion-{%s key %}"> {%- if size > 0 -%} <div class="right"><em>{%s util.ByteSizeSI(int64(size)) %}</em></div> {%- endif -%} {%s util.StringPlural(len(nvps), title) %} <em>(click to show)</em> </label> <div class="bd"><div><div> {%= renderNVPs(nvps, ps) %} </div></div></div> </li> </ul> {% endfunc %}
{% func renderNVPs(nvps har.NVPs, ps *cutil.PageState) %} <div class="overflow full-width"> <table> <tbody> {%- for _, n := range nvps -%} <tr title="{%s n.Comment %}"> <th class="shrink">{%s n.Name %}</th> <td>{%s n.Value %}</td> </tr> {%- endfor -%} </tbody> </table> </div> {% endfunc %}
|