| 452 | } |
| 453 | |
| 454 | func (m *model) setReqMethod() { |
| 455 | defer func() { |
| 456 | recover() // BUG: textinput.(*Model).CurrentSuggestion(...) cause panic first time |
| 457 | }() |
| 458 | r := regexp.MustCompile(`(?i)\b` + m.inputs[method].Value()) |
| 459 | if r.MatchString(strings.Join(allowedMethods, " ")) { |
| 460 | m.inputs[method].SetValue(m.inputs[method].CurrentSuggestion()) |
| 461 | m.req.Method = m.inputs[method].Value() |
| 462 | m.inputs[method].SetCursor(len(m.req.Method)) |
| 463 | } else { // not allowed HTTP method, reset to last saved |
| 464 | m.inputs[method].SetValue(m.req.Method) |
| 465 | m.inputs[method].CursorEnd() |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | func (m *model) setReqUrlPath() { |
| 470 | val := m.inputs[urlPath].Value() |