MCPcopy
hub / github.com/bettercap/bettercap / patchFrame

Method patchFrame

modules/api_rest/api_rest_controller.go:72–98  ·  view source on GitHub ↗
(buf []byte)

Source from the content-addressed store, hash-verified

70}
71
72func (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
100func (mod *RestAPI) showSession(w http.ResponseWriter, r *http.Request) {
101 if mod.replaying {

Callers 1

showSessionMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected