-
Notifications
You must be signed in to change notification settings - Fork 496
/
root.go
44 lines (40 loc) · 1.21 KB
/
root.go
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
42
43
44
package actions
import (
"net/http"
"net/url"
"github.com/stellar/go/protocols/horizon"
"github.com/stellar/go/services/horizon/internal/ledger"
"github.com/stellar/go/services/horizon/internal/resourceadapter"
)
type GetRootHandler struct {
LedgerState *ledger.State
CoreStateGetter
NetworkPassphrase string
FriendbotURL *url.URL
HorizonVersion string
}
func (handler GetRootHandler) GetResource(w HeaderWriter, r *http.Request) (interface{}, error) {
var res horizon.Root
templates := map[string]string{
"accounts": AccountsQuery{}.URITemplate(),
"claimableBalances": ClaimableBalancesQuery{}.URITemplate(),
"liquidityPools": LiquidityPoolsQuery{}.URITemplate(),
"offers": OffersQuery{}.URITemplate(),
"strictReceivePaths": StrictReceivePathsQuery{}.URITemplate(),
"strictSendPaths": FindFixedPathsQuery{}.URITemplate(),
}
coreState := handler.GetCoreState()
resourceadapter.PopulateRoot(
r.Context(),
&res,
handler.LedgerState.CurrentStatus(),
handler.HorizonVersion,
coreState.CoreVersion,
handler.NetworkPassphrase,
coreState.CurrentProtocolVersion,
coreState.CoreSupportedProtocolVersion,
handler.FriendbotURL,
templates,
)
return res, nil
}