From 9245b52a4b1544785a9bcc1f125b13787fb2d9ad Mon Sep 17 00:00:00 2001 From: Snowiest Date: Wed, 18 Sep 2024 21:04:21 +0800 Subject: [PATCH] =?UTF-8?q?Fix:=20=E4=BF=AE=E6=94=B9=E6=88=90=E5=91=98?= =?UTF-8?q?=E5=8F=AF=E8=A7=81=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lcu.go | 4 ++-- my.go | 14 +++++++------- sgp.go | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lcu.go b/lcu.go index 15975b6..e083f96 100644 --- a/lcu.go +++ b/lcu.go @@ -19,7 +19,7 @@ type Lcu struct { Client *http.Client Port string Auth BasicAuth - authTransport AuthTransport + authTransport authTransport websocket lcuWebsocket } @@ -55,7 +55,7 @@ func NewLcuClient(port string, auth BasicAuth) *Lcu { lcu := new(Lcu) lcu.Port = port lcu.Auth = auth - lcu.authTransport = AuthTransport{ + lcu.authTransport = authTransport{ &localTransport{ &http.Transport{ TLSClientConfig: &tls.Config{ diff --git a/my.go b/my.go index 20dcaf2..01edb05 100644 --- a/my.go +++ b/my.go @@ -13,7 +13,7 @@ import ( const remain = "Go!!!!!!!!!" -type ErrorResponse struct { +type errorResponse struct { ErrorCode string `json:"errorCode"` HttpStatus int `json:"httpStatus"` ImplementationDetails interface{} `json:"implementationDetails"` @@ -23,17 +23,17 @@ type authSetter interface { setAuth(*http.Request) } -type AuthTransport struct { +type authTransport struct { http.RoundTripper authSetter } -func (at AuthTransport) RoundTrip(req *http.Request) (*http.Response, error) { +func (at authTransport) RoundTrip(req *http.Request) (*http.Response, error) { at.setAuth(req) return at.RoundTripper.RoundTrip(req) } -func httpGet(client *http.Client, url string) ([]byte, *ErrorResponse) { +func httpGet(client *http.Client, url string) ([]byte, *errorResponse) { req, _ := http.NewRequest("GET", url, nil) resp, err := client.Do(req) if resp == nil { @@ -44,14 +44,14 @@ func httpGet(client *http.Client, url string) ([]byte, *ErrorResponse) { }(resp.Body) body, _ := io.ReadAll(resp.Body) if resp.StatusCode < 200 || resp.StatusCode > 299 { - errRes := &ErrorResponse{} + errRes := &errorResponse{} _ = json.Unmarshal(body, errRes) return nil, errRes } return body, nil } -func httpPost(client *http.Client, url string, payload map[string]interface{}) ([]byte, *ErrorResponse) { +func httpPost(client *http.Client, url string, payload map[string]interface{}) ([]byte, *errorResponse) { payloadBytes, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", url, bytes.NewBuffer(payloadBytes)) resp, err := client.Do(req) @@ -63,7 +63,7 @@ func httpPost(client *http.Client, url string, payload map[string]interface{}) ( }(resp.Body) body, _ := io.ReadAll(resp.Body) if resp.StatusCode < 200 || resp.StatusCode > 299 { - errRes := &ErrorResponse{} + errRes := &errorResponse{} _ = json.Unmarshal(body, errRes) return nil, errRes } diff --git a/sgp.go b/sgp.go index c0252a1..78bd096 100644 --- a/sgp.go +++ b/sgp.go @@ -60,7 +60,7 @@ func NewSgpClient(accessToken string, region Region) *Sgp { sgp.Region = region sgp.Auth = OAuth{accessToken} sgp.Client = &http.Client{ - Transport: AuthTransport{ + Transport: authTransport{ &http.Transport{ TLSClientConfig: &tls.Config{ InsecureSkipVerify: true, // 跳过证书验证