MCPcopy Create free account
hub / github.com/1buran/rHttp / View

Method View

main.go:1114–1244  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1112var rW, rH int
1113
1114func (m model) View() string {
1115 // Layout parts
1116 var (
1117 prompts, reqHeaders, resHeaders, resBodyLines []string
1118 reqUrl, resUrl, reqPayload string
1119 )
1120
1121 prompts = append(
1122 prompts,
1123 lipgloss.JoinHorizontal(lipgloss.Top, " ", m.inputs[method].View(), m.inputs[host].View()),
1124 " "+m.inputs[urlPath].View())
1125
1126 // Text inputs (key value pairs)
1127 for i := header; i < fieldsCount; i += 2 {
1128 prompts = append(
1129 prompts,
1130 lipgloss.JoinHorizontal(lipgloss.Top, " ", m.inputs[i].View(), m.inputs[i+1].View()))
1131 }
1132
1133 // Checkboxes
1134 prompts = append(
1135 prompts,
1136 lipgloss.JoinHorizontal(
1137 lipgloss.Top, " ",
1138 m.checkboxes[checkboxIndex(https)].View(),
1139 m.checkboxes[checkboxIndex(autoformat)].View(),
1140 ),
1141 )
1142
1143 // Request URL
1144 reqUrl = urlStyle.Render(
1145 lipgloss.JoinHorizontal(lipgloss.Top, m.req.Method, " ", m.req.URL.String()))
1146
1147 // Request headers
1148 reqHeaders = headersPrintf(m.req.Header)
1149
1150 // Request payload
1151 switch m.reqPayload {
1152 case formPayload:
1153 reqPayload = " " + bodyStyle.Render(formValues.Encode())
1154 case jsonPayload:
1155 reqPayload = " " + bodyStyle.Render(jsonPayloadEncoded)
1156 case file:
1157 reqPayload = " " + bodyStyle.Render(filePayload, " attached")
1158 }
1159
1160 // print response
1161 if m.reqIsExecuted() {
1162
1163 // Response URL
1164 resUrl = urlStyle.Render(
1165 lipgloss.JoinHorizontal(lipgloss.Top, m.res.Proto, " ", m.res.Status))
1166
1167 // Response headers
1168 resHeaders = headersPrintf(m.res.Header)
1169
1170 // TODO..
1171 // if m.res.Header["Content-Type"] == "application/json" {

Callers

nothing calls this directly

Calls 6

reqIsExecutedMethod · 0.95
getRespPageLinesMethod · 0.95
checkboxIndexFunction · 0.85
headersPrintfFunction · 0.85
FormatStatusBarMethod · 0.80
IsVisibleMethod · 0.80

Tested by

no test coverage detected