Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2019-02-27 18:03:02 +0300
committerKamil Trzciński <ayufan@ayufan.eu>2019-02-27 18:03:02 +0300
commitbaa975c1fbc157212a2cf832711288e2d677c6ee (patch)
treeda317c19671f660323d8df1266bee227bd220973 /internal/client
parent4b5bf347a6c57033dbfc4f66e3c8794212640cbd (diff)
Add API to request domain
Diffstat (limited to 'internal/client')
-rw-r--r--internal/client/api.go45
1 files changed, 44 insertions, 1 deletions
diff --git a/internal/client/api.go b/internal/client/api.go
index a14bbd7f..79555178 100644
--- a/internal/client/api.go
+++ b/internal/client/api.go
@@ -1,9 +1,52 @@
package client
import (
+ "encoding/json"
+ "net/http"
+ "net/url"
+
"gitlab.com/gitlab-org/gitlab-pages/internal/domain"
)
-func RequestDomain(host string) *domain.D {
+type LookupPath struct {
+ Prefix string `json:"prefix"`
+ Path string `json:"path"`
+
+ NamespaceProject bool `json:"namespace_project"`
+ HTTPSOnly bool `json:"https_only"`
+ AccessControl bool `json:"access_control"`
+ ProjectID uint64 `json:"id"`
+}
+
+type DomainResponse struct {
+ Domain string `json:"domain"`
+ Certificate string `json:"certificate"`
+ Key string `json:"certificate_key"`
+
+ LookupPath []LookupPath `json:"lookup_paths"`
+}
+
+func RequestDomain(apiUrl, host string) *domain.D {
+ var values url.Values
+ values.Add("host", host)
+
+ resp, err := http.PostForm(apiUrl+"/pages/domain", values)
+ if err != nil {
+ // Ignore here
+ return nil
+ }
+ defer resp.Body.Close()
+
+ if resp.StatusCode != 200 {
+ return nil
+ }
+
+ var domainResponse DomainResponse
+ err = json.NewDecoder(resp.Body).Decode(&domainResponse)
+ if err != nil {
+ // Ignore here
+ return nil
+ }
+
return nil
}