summaryrefslogtreecommitdiff
path: root/go/internal/gitlabnet/socketclient.go
diff options
context:
space:
mode:
authorIgor <idrozdov@gitlab.com>2019-03-21 11:53:09 +0000
committerNick Thomas <nick@gitlab.com>2019-03-21 11:53:09 +0000
commit98dbdfb758703428626d54b2a257565a44509a55 (patch)
treea3fdc408786fd0342bd3eb28ad841e70d3d7ac6e /go/internal/gitlabnet/socketclient.go
parent81bed658f083a165e65b16f7ef86c18938349e33 (diff)
downloadgitlab-shell-98dbdfb758703428626d54b2a257565a44509a55.tar.gz
Provide go implementation for 2fa_recovery_codes command
Diffstat (limited to 'go/internal/gitlabnet/socketclient.go')
-rw-r--r--go/internal/gitlabnet/socketclient.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/go/internal/gitlabnet/socketclient.go b/go/internal/gitlabnet/socketclient.go
index 3bd7c70..fd97535 100644
--- a/go/internal/gitlabnet/socketclient.go
+++ b/go/internal/gitlabnet/socketclient.go
@@ -1,7 +1,9 @@
package gitlabnet
import (
+ "bytes"
"context"
+ "encoding/json"
"net"
"net/http"
"strings"
@@ -44,3 +46,21 @@ func (c *GitlabSocketClient) Get(path string) (*http.Response, error) {
return doRequest(c.httpClient, c.config, request)
}
+
+func (c *GitlabSocketClient) Post(path string, data interface{}) (*http.Response, error) {
+ path = normalizePath(path)
+
+ jsonData, err := json.Marshal(data)
+ if err != nil {
+ return nil, err
+ }
+
+ request, err := http.NewRequest("POST", socketBaseUrl+path, bytes.NewReader(jsonData))
+ request.Header.Add("Content-Type", "application/json")
+
+ if err != nil {
+ return nil, err
+ }
+
+ return doRequest(c.httpClient, c.config, request)
+}