From bdae6008a0d8bf710ff8e46366b2258b0918ae5b Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Thu, 4 Oct 2018 12:43:52 +0200 Subject: [PATCH] generic driver now uses argv[1] and argv[2] to send method name and data --- driver/generic.mockup.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/driver/generic.mockup.go b/driver/generic.mockup.go index cf31280..8a0377b 100644 --- a/driver/generic.mockup.go +++ b/driver/generic.mockup.go @@ -23,8 +23,20 @@ func (path genericController) Get(d response.Arguments) response.Response { return *res } + // extract HTTP method + rawMethod, ok := d["_HTTP_METHOD_"] + if !ok { + res.Err = e.UncallableController + return *res + } + method, ok := rawMethod.(string) + if !ok { + res.Err = e.UncallableController + return *res + } + /* (2) Try to load command with -> stdout */ - cmd := exec.Command(string(path), string(stdin)) + cmd := exec.Command(string(path), method, string(stdin)) stdout, err := cmd.Output() if err != nil { @@ -126,7 +138,7 @@ type genericChecker string func (path genericChecker) Match(_type string) bool { /* (1) Try to load command with -> stdout */ - cmd := exec.Command(string(path), _type) + cmd := exec.Command(string(path), "MATCH", _type) stdout, err := cmd.Output() if err != nil { @@ -151,7 +163,7 @@ func (path genericChecker) Check(_value interface{}) bool { } /* (2) Try to load command with -> stdout */ - cmd := exec.Command(string(path), string(stdin)) + cmd := exec.Command(string(path), "CHECK", string(stdin)) stdout, err := cmd.Output() if err != nil {