Documentation ¶
Index ¶
- Constants
- Variables
- func AssertOKResponse(t *testing.T, req *http.Request, expectedRespBody string, backend *mock.API)
- func AssertResponse(t *testing.T, req *http.Request, status int, expectedRespBody string, ...)
- func ExecuteLegacyWsRequest(req *http.Request, stateStreamApi state_stream.API, ...)
- func ExecuteRequest(req *http.Request, backend access.API) *httptest.ResponseRecorder
- func URLToRoute(url string) (string, error)
- type RouterBuilder
- func (b *RouterBuilder) AddLegacyWebsocketsRoutes(stateStreamApi state_stream.API, chain flow.Chain, ...) *RouterBuilder
- func (b *RouterBuilder) AddRestRoutes(backend access.API, chain flow.Chain, maxRequestSize int64) *RouterBuilder
- func (b *RouterBuilder) AddWebsocketsRoute(chain flow.Chain, config websockets.Config, streamApi state_stream.API, ...) *RouterBuilder
- func (b *RouterBuilder) Build() *mux.Router
- type TestHijackResponseRecorder
Constants ¶
View Source
const ( ExpandableFieldPayload = "payload" ExpandableExecutionResult = "execution_result" SealedHeightQueryParam = "sealed" FinalHeightQueryParam = "final" StartHeightQueryParam = "start_height" EndHeightQueryParam = "end_height" HeightQueryParam = "height" StartBlockIdQueryParam = "start_block_id" EventTypesQueryParams = "event_types" AddressesQueryParams = "addresses" ContractsQueryParams = "contracts" HeartbeatIntervalQueryParam = "heartbeat_interval" )
Variables ¶
View Source
var Routes = []route{{ Method: http.MethodGet, Pattern: "/transactions/{id}", Name: "getTransactionByID", Handler: routes.GetTransactionByID, }, { Method: http.MethodPost, Pattern: "/transactions", Name: "createTransaction", Handler: routes.CreateTransaction, }, { Method: http.MethodGet, Pattern: "/transaction_results/{id}", Name: "getTransactionResultByID", Handler: routes.GetTransactionResultByID, }, { Method: http.MethodGet, Pattern: "/blocks/{id}", Name: "getBlocksByIDs", Handler: routes.GetBlocksByIDs, }, { Method: http.MethodGet, Pattern: "/blocks", Name: "getBlocksByHeight", Handler: routes.GetBlocksByHeight, }, { Method: http.MethodGet, Pattern: "/blocks/{id}/payload", Name: "getBlockPayloadByID", Handler: routes.GetBlockPayloadByID, }, { Method: http.MethodGet, Pattern: "/execution_results/{id}", Name: "getExecutionResultByID", Handler: routes.GetExecutionResultByID, }, { Method: http.MethodGet, Pattern: "/execution_results", Name: "getExecutionResultByBlockID", Handler: routes.GetExecutionResultsByBlockIDs, }, { Method: http.MethodGet, Pattern: "/collections/{id}", Name: "getCollectionByID", Handler: routes.GetCollectionByID, }, { Method: http.MethodPost, Pattern: "/scripts", Name: "executeScript", Handler: routes.ExecuteScript, }, { Method: http.MethodGet, Pattern: "/accounts/{address}", Name: "getAccount", Handler: routes.GetAccount, }, { Method: http.MethodGet, Pattern: "/accounts/{address}/balance", Name: "getAccountBalance", Handler: routes.GetAccountBalance, }, { Method: http.MethodGet, Pattern: "/accounts/{address}/keys/{index}", Name: "getAccountKeyByIndex", Handler: routes.GetAccountKeyByIndex, }, { Method: http.MethodGet, Pattern: "/accounts/{address}/keys", Name: "getAccountKeys", Handler: routes.GetAccountKeys, }, { Method: http.MethodGet, Pattern: "/events", Name: "getEvents", Handler: routes.GetEvents, }, { Method: http.MethodGet, Pattern: "/network/parameters", Name: "getNetworkParameters", Handler: routes.GetNetworkParameters, }, { Method: http.MethodGet, Pattern: "/node_version_info", Name: "getNodeVersionInfo", Handler: routes.GetNodeVersionInfo, }}
View Source
var WSLegacyRoutes = []wsLegacyRoute{{ Method: http.MethodGet, Pattern: "/subscribe_events", Name: "subscribeEvents", Handler: routes.SubscribeEvents, }}
Functions ¶
func AssertOKResponse ¶
func AssertResponse ¶
func ExecuteLegacyWsRequest ¶
func ExecuteLegacyWsRequest(req *http.Request, stateStreamApi state_stream.API, responseRecorder *TestHijackResponseRecorder, chain flow.Chain)
func ExecuteRequest ¶
func URLToRoute ¶
Types ¶
type RouterBuilder ¶
type RouterBuilder struct {
// contains filtered or unexported fields
}
RouterBuilder is a utility for building HTTP routers with common middleware and routes.
func NewRouterBuilder ¶
func NewRouterBuilder( logger zerolog.Logger, restCollector module.RestMetrics) *RouterBuilder
NewRouterBuilder creates a new RouterBuilder instance with common middleware and a v1 sub-router.
func (*RouterBuilder) AddLegacyWebsocketsRoutes ¶
func (b *RouterBuilder) AddLegacyWebsocketsRoutes( stateStreamApi state_stream.API, chain flow.Chain, stateStreamConfig backend.Config, maxRequestSize int64, ) *RouterBuilder
AddLegacyWebsocketsRoutes adds WebSocket routes to the router.
func (*RouterBuilder) AddRestRoutes ¶
func (b *RouterBuilder) AddRestRoutes( backend access.API, chain flow.Chain, maxRequestSize int64, ) *RouterBuilder
AddRestRoutes adds rest routes to the router.
func (*RouterBuilder) AddWebsocketsRoute ¶
func (b *RouterBuilder) AddWebsocketsRoute( chain flow.Chain, config websockets.Config, streamApi state_stream.API, streamConfig backend.Config, maxRequestSize int64, ) *RouterBuilder
func (*RouterBuilder) Build ¶
func (b *RouterBuilder) Build() *mux.Router
type TestHijackResponseRecorder ¶
type TestHijackResponseRecorder struct { *httptest.ResponseRecorder Closed chan struct{} ResponseBuff *bytes.Buffer }
TestHijackResponseRecorder is a custom ResponseRecorder that implements the http.Hijacker interface for testing WebSocket connections and hijacking.
func NewTestHijackResponseRecorder ¶
func NewTestHijackResponseRecorder() *TestHijackResponseRecorder
NewTestHijackResponseRecorder creates a new instance of TestHijackResponseRecorder.
func (*TestHijackResponseRecorder) Close ¶
func (w *TestHijackResponseRecorder) Close() error
func (*TestHijackResponseRecorder) Hijack ¶
func (w *TestHijackResponseRecorder) Hijack() (net.Conn, *bufio.ReadWriter, error)
Hijack implements the http.Hijacker interface by returning a fakeNetConn and a bufio.ReadWriter that simulate a hijacked connection.
Click to show internal directories.
Click to hide internal directories.