-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added get all application users code in requestx package.
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package requestx | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/spf13/viper" | ||
) | ||
|
||
// AllApplicationUsers gets all the users for a application from kavach | ||
func AllApplicationUsers(appSlug string, oID, uID uint) (*http.Response, error) { | ||
if appSlug == "" { | ||
return nil, errors.New("appSlug parameter cannot be empty") | ||
} | ||
|
||
resp, err := Request("GET", viper.GetString("kavach_url")+"/users/application?application="+appSlug, nil, map[string]string{ | ||
"X-User": fmt.Sprint(uID), | ||
"X-Organisation": fmt.Sprint(oID), | ||
}) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if resp.StatusCode > 500 { | ||
return nil, errors.New("something went wrong") | ||
} | ||
|
||
return resp, nil | ||
} |