Cache TTL of 5 minutes
(token *string, method string, url string, body io.Reader)
| 403 | var userCache = bridge.NewCache(5 * time.Minute) // Cache TTL of 5 minutes |
| 404 | |
| 405 | func SendRequest(token *string, method string, url string, body io.Reader) (*http.Response, error) { |
| 406 | client := &http.Client{} |
| 407 | req, err := http.NewRequest(method, url, body) |
| 408 | if err != nil { |
| 409 | return nil, err |
| 410 | } |
| 411 | if token != nil { |
| 412 | req.Header.Set("Authorization", "Bearer "+*token) |
| 413 | } |
| 414 | req.Header.Set("Content-Type", "application/json") // 99% sure all bluesky requests are json. |
| 415 | req.Header.Set("User-Agent", "ATwitterBridge/1.0") |
| 416 | |
| 417 | resp, err := client.Do(req) |
| 418 | if err != nil { |
| 419 | return nil, err |
| 420 | } |
| 421 | |
| 422 | return resp, nil |
| 423 | } |
| 424 | |
| 425 | func SendRequestWithContentType(token *string, method string, url string, body io.Reader, content_type string) (*http.Response, error) { |
| 426 | client := &http.Client{} |
no test coverage detected