mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
client: allow using custom http client for .well-known resolution
This commit is contained in:
parent
4866da5200
commit
65a64c8044
1 changed files with 4 additions and 1 deletions
|
|
@ -139,6 +139,10 @@ type IdentityServerInfo struct {
|
|||
// Use ParseUserID to extract the server name from a user ID.
|
||||
// https://spec.matrix.org/v1.2/client-server-api/#server-discovery
|
||||
func DiscoverClientAPI(ctx context.Context, serverName string) (*ClientWellKnown, error) {
|
||||
return DiscoverClientAPIWithClient(ctx, &http.Client{Timeout: 30 * time.Second}, serverName)
|
||||
}
|
||||
|
||||
func DiscoverClientAPIWithClient(ctx context.Context, client *http.Client, serverName string) (*ClientWellKnown, error) {
|
||||
wellKnownURL := url.URL{
|
||||
Scheme: "https",
|
||||
Host: serverName,
|
||||
|
|
@ -153,7 +157,6 @@ func DiscoverClientAPI(ctx context.Context, serverName string) (*ClientWellKnown
|
|||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", DefaultUserAgent+" (.well-known fetcher)")
|
||||
|
||||
client := &http.Client{Timeout: 30 * time.Second}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue