izliang commented on code in PR #514:
URL:
https://github.com/apache/incubator-hugegraph-toolchain/pull/514#discussion_r1328052389
##########
hugegraph-client-go/hgtransport/hgtransport.go:
##########
@@ -0,0 +1,246 @@
+package hgtransport
+
+import (
+ "bytes"
+ "fmt"
+ "io/ioutil"
+ "net/http"
+ "net/url"
+ "regexp"
+ "runtime"
+ "strings"
+ "time"
+
+ "hugegraph.apache.org/client-go/internal/version"
+)
+
+// Version returns the package version as a string.
+//
+const Version = version.Client
+
+var (
+ userAgent string
+ reGoVersion = regexp.MustCompile(`go(\d+\.\d+\..+)`)
+)
+
+func init() {
+ userAgent = initUserAgent()
+}
+
+// Interface defines the interface for HTTP client.
+//
+type Interface interface {
+ Perform(*http.Request) (*http.Response, error)
+}
+
+// Config represents the configuration of HTTP client.
+//
+type Config struct {
+ URL *url.URL
+ Username string
+ Password string
+ GraphSpace string
+ Graph string
+
+ Transport http.RoundTripper
+ Logger Logger
+}
+
+// Client represents the HTTP client.
+//
+type Client struct {
+ url *url.URL
+ username string
+ password string
+ graphspaces string
+ graph string
+
+ transport http.RoundTripper
+ logger Logger
+}
+
+// New creates new HTTP client.
+//
+// http.DefaultTransport will be used if no transport is passed in the
configuration.
+//
+func New(cfg Config) *Client {
+ if cfg.Transport == nil {
+ cfg.Transport = http.DefaultTransport
+ }
+
+ return &Client{
+ url: cfg.URL,
+ username: cfg.Username,
+ password: cfg.Password,
+ graphspaces: cfg.GraphSpace,
+ graph: cfg.Graph,
+ transport: cfg.Transport,
+ logger: cfg.Logger,
+ }
+}
+
+// Perform executes the request and returns a response or error.
+//
+func (c *Client) Perform(req *http.Request) (*http.Response, error) {
Review Comment:
Okay, during the debugging process, I found that some APIs needed to modify
the information in the request body, such as graph space and graph name, so I
made the modifications. I'll think about how to solve this problem
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]