-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdetector.go
More file actions
33 lines (29 loc) · 788 Bytes
/
detector.go
File metadata and controls
33 lines (29 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package GoDeepStack
import (
"github.com/aavgoust02/GoDeepStack/util"
"github.com/imroc/req/v3"
"log"
"net/url"
)
type Detector interface {
Endpoint() string
}
type AbstractDetector struct {
Detector
Client *DeepStack
}
func (a *AbstractDetector) SendRequest(files *util.Files, additionalParameters *util.Parameters, out interface{}) interface{} {
client := req.C().R()
if a.Client.ApiKey != "" {
var apiKey url.Values
apiKey.Add("api_key", a.Client.ApiKey)
client.SetFormDataFromValues(apiKey)
}
request := client.SetFiles(files.Files).SetFormData(additionalParameters.Parameters).SetResult(&out)
response, err := request.Post(a.Endpoint())
util.Check(err)
if !response.IsSuccess() {
log.Fatalf("Unable to run query [%d]", response.StatusCode)
}
return out
}