mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 05:23:19 -07:00
new: implemented GET /api/events route (ref #5).
This commit is contained in:
parent
ee4b783015
commit
269d7d845b
14 changed files with 172 additions and 38 deletions
|
@ -11,13 +11,15 @@ type Environment struct {
|
|||
Padding int `json:"-"`
|
||||
Storage map[string]string `json:"storage"`
|
||||
lock *sync.Mutex
|
||||
sess *Session
|
||||
}
|
||||
|
||||
func NewEnvironment() *Environment {
|
||||
func NewEnvironment(s *Session) *Environment {
|
||||
env := &Environment{
|
||||
Padding: 0,
|
||||
Storage: make(map[string]string),
|
||||
lock: &sync.Mutex{},
|
||||
sess: s,
|
||||
}
|
||||
|
||||
return env
|
||||
|
@ -39,6 +41,14 @@ func (env *Environment) Set(name, value string) string {
|
|||
old, _ := env.Storage[name]
|
||||
env.Storage[name] = value
|
||||
|
||||
env.sess.Events.Add("env.change", struct {
|
||||
name string
|
||||
value string
|
||||
}{
|
||||
name,
|
||||
value,
|
||||
})
|
||||
|
||||
width := len(name)
|
||||
if width > env.Padding {
|
||||
env.Padding = width
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue