| 70 | } |
| 71 | |
| 72 | func (mod *RestAPI) patchFrame(buf []byte) (frame map[string]interface{}, err error) { |
| 73 | // this is ugly but necessary: since we're replaying, the |
| 74 | // api.rest state object is filled with *old* values (the |
| 75 | // recorded ones), but the UI needs updated values at least |
| 76 | // of that in order to understand that a replay is going on |
| 77 | // and where we are at it. So we need to parse the record |
| 78 | // back into a session object and update only the api.rest.state |
| 79 | frame = make(map[string]interface{}) |
| 80 | |
| 81 | if err = json.Unmarshal(buf, &frame); err != nil { |
| 82 | return |
| 83 | } |
| 84 | |
| 85 | for _, i := range frame["modules"].([]interface{}) { |
| 86 | m := i.(map[string]interface{}) |
| 87 | if m["name"] == "api.rest" { |
| 88 | state := m["state"].(map[string]interface{}) |
| 89 | mod.State.Range(func(key interface{}, value interface{}) bool { |
| 90 | state[key.(string)] = value |
| 91 | return true |
| 92 | }) |
| 93 | break |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | return |
| 98 | } |
| 99 | |
| 100 | func (mod *RestAPI) showSession(w http.ResponseWriter, r *http.Request) { |
| 101 | if mod.replaying { |