MCPcopy
hub / github.com/IceWhaleTech/CasaOS / Request

Method Request

drivers/onedrive/util.go:121–147  ·  view source on GitHub ↗
(url string, method string, callback base.ReqCallback, resp interface{})

Source from the content-addressed store, hash-verified

119}
120
121func (d *Onedrive) Request(url string, method string, callback base.ReqCallback, resp interface{}) ([]byte, error) {
122 req := base.RestyClient.R()
123 req.SetHeader("Authorization", "Bearer "+d.AccessToken)
124 if callback != nil {
125 callback(req)
126 }
127 if resp != nil {
128 req.SetResult(resp)
129 }
130 var e RespErr
131 req.SetError(&e)
132 res, err := req.Execute(method, url)
133 if err != nil {
134 return nil, err
135 }
136 if e.Error.Code != "" {
137 if e.Error.Code == "InvalidAuthenticationToken" {
138 err = d.refreshToken()
139 if err != nil {
140 return nil, err
141 }
142 return d.Request(url, method, callback, resp)
143 }
144 return nil, errors.New(e.Error.Message)
145 }
146 return res.Body(), nil
147}
148
149func GetConfig() Onedrive {
150 config := Onedrive{}

Callers 15

GetInfoMethod · 0.95
GetSpaceSizeMethod · 0.95
DefaultPostFormFunction · 0.80
InitV2RouterFunction · 0.80
InitV1RouterFunction · 0.80
GetFileTestMethod · 0.80
ZerotierProxyFunction · 0.80
GetDownloadFileFunction · 0.80
GetDownloadSingleFileFunction · 0.80
PostFileUploadFunction · 0.80
PostFileOctetFunction · 0.80
ConnectWebSocketFunction · 0.80

Calls 1

refreshTokenMethod · 0.95

Tested by

no test coverage detected