MCPcopy Index your code
hub / github.com/chain/Core / buildHandler

Method buildHandler

core/api.go:129–211  ·  view source on GitHub ↗

buildHandler adds the Core API routes to a preexisting http handler.

()

Source from the content-addressed store, hash-verified

127
128// buildHandler adds the Core API routes to a preexisting http handler.
129func (a *API) buildHandler() {
130 needConfig := a.needConfig()
131
132 resetAllowed := func(h http.Handler) http.Handler { return alwaysError(errNoReset) }
133 if config.BuildConfig.Reset {
134 resetAllowed = func(h http.Handler) http.Handler { return h }
135 }
136
137 m := a.mux
138 m.Handle("/", alwaysError(errNotFound))
139
140 m.Handle("/create-account", needConfig(a.createAccount))
141 m.Handle("/create-asset", needConfig(a.createAsset))
142 m.Handle("/update-account-tags", needConfig(a.updateAccountTags))
143 m.Handle("/update-asset-tags", needConfig(a.updateAssetTags))
144 m.Handle("/build-transaction", needConfig(a.build))
145 m.Handle("/submit-transaction", needConfig(a.submit))
146 m.Handle("/create-control-program", needConfig(a.createControlProgram)) // DEPRECATED
147 m.Handle("/create-account-receiver", needConfig(a.createAccountReceiver))
148 m.Handle("/create-transaction-feed", needConfig(a.createTxFeed))
149 m.Handle("/get-transaction-feed", needConfig(a.getTxFeed))
150 m.Handle("/update-transaction-feed", needConfig(a.updateTxFeed))
151 m.Handle("/delete-transaction-feed", needConfig(a.deleteTxFeed))
152 m.Handle("/mockhsm", alwaysError(errNoMockHSM))
153 m.Handle("/list-accounts", needConfig(a.listAccounts))
154 m.Handle("/list-assets", needConfig(a.listAssets))
155 m.Handle("/list-transaction-feeds", needConfig(a.listTxFeeds))
156 m.Handle("/list-transactions", needConfig(a.listTransactions))
157 m.Handle("/list-balances", needConfig(a.listBalances))
158 m.Handle("/list-unspent-outputs", needConfig(a.listUnspentOutputs))
159 m.Handle("/reset", resetAllowed(needConfig(a.reset)))
160
161 m.Handle(crosscoreRPCPrefix+"submit", needConfig(func(ctx context.Context, tx *legacy.Tx) error {
162 return a.submitter.Submit(ctx, tx)
163 }))
164 m.Handle(crosscoreRPCPrefix+"get-block", needConfig(a.getBlockRPC))
165 m.Handle(crosscoreRPCPrefix+"get-snapshot-info", needConfig(a.getSnapshotInfoRPC))
166 m.Handle(crosscoreRPCPrefix+"get-snapshot", http.HandlerFunc(a.getSnapshotRPC))
167 m.Handle(crosscoreRPCPrefix+"signer/sign-block", needConfig(a.leaderSignHandler(a.signer)))
168 m.Handle(crosscoreRPCPrefix+"block-height", needConfig(func(ctx context.Context) map[string]uint64 {
169 h := a.chain.Height()
170 return map[string]uint64{
171 "block_height": h,
172 }
173 }))
174
175 m.Handle("/list-authorization-grants", jsonHandler(a.listGrants))
176 m.Handle("/create-authorization-grant", jsonHandler(a.createGrant))
177 m.Handle("/delete-authorization-grant", jsonHandler(a.deleteGrant))
178 m.Handle("/create-access-token", jsonHandler(a.createAccessToken))
179 m.Handle("/list-access-tokens", jsonHandler(a.listAccessTokens))
180 m.Handle("/delete-access-token", jsonHandler(a.deleteAccessToken))
181 m.Handle("/add-allowed-member", jsonHandler(a.addAllowedMember))
182 m.Handle("/configure", jsonHandler(a.configure))
183 m.Handle("/info", jsonHandler(a.info))
184
185 m.Handle("/debug/vars", expvar.Handler())
186 m.Handle("/debug/pprof/", http.HandlerFunc(pprof.Index))

Callers 4

TestAuthzFunction · 0.95
TestMuxFunction · 0.95
RunUnconfiguredFunction · 0.95
RunFunction · 0.95

Calls 15

needConfigMethod · 0.95
leaderSignHandlerMethod · 0.95
alwaysErrorFunction · 0.85
jsonHandlerFunction · 0.85
latencyFunction · 0.85
maxBytesFunction · 0.85
webAssetsHandlerFunction · 0.85
healthHandlerFunction · 0.85
coreCounterFunction · 0.85
timeoutContextHandlerFunction · 0.85
blockchainIDHandlerFunction · 0.85
RecordSinceMethod · 0.80

Tested by 2

TestAuthzFunction · 0.76
TestMuxFunction · 0.76