-
Notifications
You must be signed in to change notification settings - Fork 2
/
authas.go
34 lines (27 loc) · 936 Bytes
/
authas.go
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
34
package hintegrate
import (
"encoding/json"
"github.com/hailo-platform/H2O/hintegrate/request"
"github.com/hailo-platform/H2O/hintegrate/validators"
"github.com/hailo-platform/H2O/hintegrate/variables"
)
// AuthAs will attempt to call `authas` on the login service
func AuthAs(c *request.Context, application, username, deviceType string) (*request.ApiReturn, error) {
requestData := map[string]interface{}{
"application": application,
"username": username,
"deviceType": deviceType,
}
reqJson, _ := json.Marshal(requestData)
endpoint := "authas"
postData := map[string]string{
"service": serviceName,
"endpoint": endpoint,
"request": string(reqJson),
}
rsp, err := c.Post().SetHost("callapi_host").
PostDataMap(postData).SetPath("/rpc").
Run(serviceName+"."+endpoint, validators.Status2xxValidator())
ret := &request.ApiReturn{Raw: rsp, ParsedVars: variables.NewVariables()}
return ret, err
}