mirror of
https://github.com/bettercap/bettercap
synced 2025-07-15 01:23:42 -07:00
new: properly exposing module handlers and parameters from api.rest
This commit is contained in:
parent
87ac32cd6b
commit
b98db78926
4 changed files with 64 additions and 22 deletions
|
@ -1,6 +1,7 @@
|
|||
package session
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strconv"
|
||||
|
@ -49,3 +50,20 @@ func (h *ModuleHandler) Parse(line string) (bool, []string) {
|
|||
}
|
||||
return false, nil
|
||||
}
|
||||
|
||||
type JSONModuleHandler struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Parser string `json:"parser"`
|
||||
}
|
||||
|
||||
func (h ModuleHandler) MarshalJSON() ([]byte, error) {
|
||||
j := JSONModuleHandler{
|
||||
Name: h.Name,
|
||||
Description: h.Description,
|
||||
}
|
||||
if h.Parser != nil {
|
||||
j.Parser = h.Parser.String()
|
||||
}
|
||||
return json.Marshal(j)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue