GetMode will go the state endpoint in Hoverfly, parse the JSON response and return the mode of Hoverfly
(target configuration.Target)
| 10 | |
| 11 | // GetMode will go the state endpoint in Hoverfly, parse the JSON response and return the mode of Hoverfly |
| 12 | func GetMode(target configuration.Target) (*v2.ModeView, error) { |
| 13 | response, err := doRequest(target, "GET", v2ApiMode, "", nil) |
| 14 | if err != nil { |
| 15 | return nil, err |
| 16 | } |
| 17 | |
| 18 | defer response.Body.Close() |
| 19 | |
| 20 | err = handleResponseError(response, "Could not retrieve mode") |
| 21 | if err != nil { |
| 22 | return nil, err |
| 23 | } |
| 24 | |
| 25 | var modeView v2.ModeView |
| 26 | |
| 27 | err = UnmarshalToInterface(response, &modeView) |
| 28 | if err != nil { |
| 29 | return nil, err |
| 30 | } |
| 31 | |
| 32 | return &modeView, nil |
| 33 | } |
| 34 | |
| 35 | // Set will go the state endpoint in Hoverfly, sending JSON that will set the mode of Hoverfly |
| 36 | func SetModeWithArguments(target configuration.Target, modeView *v2.ModeView) (string, error) { |