MCPcopy Create free account
hub / github.com/daodst/chat / AddPublicRoutes

Function AddPublicRoutes

federationapi/federationapi.go:49–93  ·  view source on GitHub ↗

AddPublicRoutes sets up and registers HTTP handlers on the base API muxes for the FederationAPI component.

(
	base *base.BaseDendrite,
	userAPI userapi.UserInternalAPI,
	federation *gomatrixserverlib.FederationClient,
	keyRing gomatrixserverlib.JSONVerifier,
	rsAPI roomserverAPI.FederationRoomserverAPI,
	fedAPI federationAPI.FederationInternalAPI,
	keyAPI keyserverAPI.FederationKeyAPI,
	servers federationAPI.ServersInRoomProvider,
)

Source from the content-addressed store, hash-verified

47
48// AddPublicRoutes sets up and registers HTTP handlers on the base API muxes for the FederationAPI component.
49func AddPublicRoutes(
50 base *base.BaseDendrite,
51 userAPI userapi.UserInternalAPI,
52 federation *gomatrixserverlib.FederationClient,
53 keyRing gomatrixserverlib.JSONVerifier,
54 rsAPI roomserverAPI.FederationRoomserverAPI,
55 fedAPI federationAPI.FederationInternalAPI,
56 keyAPI keyserverAPI.FederationKeyAPI,
57 servers federationAPI.ServersInRoomProvider,
58) {
59 cfg := &base.Cfg.FederationAPI
60 mscCfg := &base.Cfg.MSCs
61 js, _ := base.NATS.Prepare(base.ProcessContext, &cfg.Matrix.JetStream)
62 producer := &producers.SyncAPIProducer{
63 JetStream: js,
64 TopicReceiptEvent: cfg.Matrix.JetStream.Prefixed(jetstream.OutputReceiptEvent),
65 TopicSendToDeviceEvent: cfg.Matrix.JetStream.Prefixed(jetstream.OutputSendToDeviceEvent),
66 TopicTypingEvent: cfg.Matrix.JetStream.Prefixed(jetstream.OutputTypingEvent),
67 TopicPresenceEvent: cfg.Matrix.JetStream.Prefixed(jetstream.OutputPresenceEvent),
68 TopicDeviceListUpdate: cfg.Matrix.JetStream.Prefixed(jetstream.InputDeviceListUpdate),
69 ServerName: cfg.Matrix.ServerName,
70 UserAPI: userAPI,
71 }
72
73 // the federationapi component is a bit unique in that it attaches public routes AND serves
74 // internal APIs (because it used to be 2 components: the 2nd being fedsender). As a result,
75 // the constructor shape is a bit wonky in that it is not valid to AddPublicRoutes without a
76 // concrete impl of FederationInternalAPI as the public routes and the internal API _should_
77 // be the same thing now.
78 f, ok := fedAPI.(*internal.FederationInternalAPI)
79 if !ok {
80 panic("federationapi.AddPublicRoutes called with a FederationInternalAPI impl which was not " +
81 "FederationInternalAPI. This is a programming error.")
82 }
83
84 routing.Setup(
85 base.PublicFederationAPIMux,
86 base.PublicKeyAPIMux,
87 base.PublicWellKnownAPIMux,
88 cfg,
89 rsAPI, f, keyRing,
90 federation, userAPI, keyAPI, mscCfg,
91 servers, producer,
92 )
93}
94
95// NewInternalAPI returns a concerete implementation of the internal API. Callers
96// can call functions directly on the returned API or via an HTTP interface using AddInternalRoutes.

Callers

nothing calls this directly

Calls 3

PrefixedMethod · 0.80
PrepareMethod · 0.65
SetupMethod · 0.65

Tested by

no test coverage detected