Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Go Shared packages
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dragon Law Go Components
Go Shared packages
Commits
d829f148
Commit
d829f148
authored
6 years ago
by
Mac Choi
Browse files
Options
Downloads
Patches
Plain Diff
add core api
parent
1dded154
No related branches found
Branches containing commit
Tags
v0.0.8.13
Tags containing commit
No related merge requests found
Pipeline
#28334
failed
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
zegal/core.go
+36
-0
36 additions, 0 deletions
zegal/core.go
with
36 additions
and
0 deletions
zegal/core.go
0 → 100644
+
36
−
0
View file @
d829f148
package
zegal
import
(
"bytes"
"encoding/json"
"errors"
"io/ioutil"
"net/http"
)
func
(
api
*
ApiConfig
)
DLServer
(
method
,
path
string
,
reqBody
interface
{},
zh
*
ZegalHeader
)
([]
byte
,
error
)
{
reqBodyByte
,
_
:=
json
.
Marshal
(
reqBody
)
req
,
err
:=
http
.
NewRequest
(
method
,
api
.
Core
+
path
,
bytes
.
NewBuffer
(
reqBodyByte
))
if
err
!=
nil
{
return
[]
byte
{},
err
}
// Set Header
req
.
Header
.
Add
(
"X-Dragon-Law-API-Version"
,
zh
.
Version
)
req
.
Header
.
Add
(
"zegalapi-origin"
,
zh
.
Origin
)
req
.
Header
.
Add
(
"X-Dragon-Law-Username"
,
zh
.
Email
)
req
.
Header
.
Add
(
"X-Dragon-Law-Dragonball"
,
zh
.
Token
)
req
.
Header
.
Add
(
"Content-Type"
,
"application/json"
)
// Call
res
,
err
:=
Client
.
Do
(
req
)
if
err
!=
nil
{
return
[]
byte
{},
err
}
body
,
err
:=
ioutil
.
ReadAll
(
res
.
Body
)
if
err
!=
nil
{
return
[]
byte
{},
err
}
else
if
res
.
StatusCode
!=
200
&&
res
.
StatusCode
!=
201
&&
res
.
StatusCode
!=
202
{
err
=
errors
.
New
(
string
(
body
))
return
[]
byte
{},
err
}
return
body
,
nil
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment