new: properly exposing module handlers and parameters from api.rest

This commit is contained in:
evilsocket 2018-09-29 12:20:22 +02:00
parent 87ac32cd6b
commit b98db78926
4 changed files with 64 additions and 22 deletions

View file

@ -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)
}