blob: d643526bddddae956a53fad7b11001a0554d6f9f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
package api
import (
"errors"
"net/http"
"github.com/matrix-org/dendrite/common/caching"
fsInputAPI "github.com/matrix-org/dendrite/federationsender/api"
)
type httpRoomserverInternalAPI struct {
roomserverURL string
httpClient *http.Client
fsAPI fsInputAPI.FederationSenderInternalAPI
immutableCache caching.ImmutableCache
}
// NewRoomserverInputAPIHTTP creates a RoomserverInputAPI implemented by talking to a HTTP POST API.
// If httpClient is nil an error is returned
func NewRoomserverInternalAPIHTTP(
roomserverURL string,
httpClient *http.Client,
//fsInputAPI fsAPI.FederationSenderInternalAPI,
immutableCache caching.ImmutableCache,
) (RoomserverInternalAPI, error) {
if httpClient == nil {
return nil, errors.New("NewRoomserverInternalAPIHTTP: httpClient is <nil>")
}
return &httpRoomserverInternalAPI{
roomserverURL: roomserverURL,
httpClient: httpClient,
immutableCache: immutableCache,
}, nil
}
// SetFederationSenderInputAPI passes in a federation sender input API reference
// so that we can avoid the chicken-and-egg problem of both the roomserver input API
// and the federation sender input API being interdependent.
func (h *httpRoomserverInternalAPI) SetFederationSenderAPI(fsAPI fsInputAPI.FederationSenderInternalAPI) {
h.fsAPI = fsAPI
}
|