# README

Server

GoDoc

The Server package reduces the work required to write your own Rosetta server. In short, this package takes care of the basics (boilerplate server code and request validation) so that you can focus on code that is unique to your implementation.

Installation

go get github.com/HelloKashif/rosetta-sdk-go/server

Components

Router

The router is a Mux router that routes traffic to the correct controller.

Controller

Contollers are automatically generated code that specify an interface that a service must implement.

Services

Services are implemented by you to populate responses. These services are invoked by controllers.

Recommended Folder Structure

main.go
/services
  block_service.go
  network_service.go
  ...

Examples

Check out the examples to see how easy it is to create your own server.

# Functions

CorsMiddleware handles CORS and ensures OPTIONS requests are handled properly.
EncodeJSONResponse uses the json encoder to write an interface to the http response with an optional status code.
LoggerMiddleware is a simple logger middleware that prints the requests in an ad-hoc fashion to the stdlib's log.
NewAccountAPIController creates a default api controller.
NewBlockAPIController creates a default api controller.
NewCallAPIController creates a default api controller.
NewConstructionAPIController creates a default api controller.
NewEventsAPIController creates a default api controller.
NewMempoolAPIController creates a default api controller.
NewNetworkAPIController creates a default api controller.
NewRouter creates a new router for any number of api routers.
NewSearchAPIController creates a default api controller.

# Structs

A AccountAPIController binds http requests to an api service and writes the service results to the http response.
A BlockAPIController binds http requests to an api service and writes the service results to the http response.
A CallAPIController binds http requests to an api service and writes the service results to the http response.
A ConstructionAPIController binds http requests to an api service and writes the service results to the http response.
A EventsAPIController binds http requests to an api service and writes the service results to the http response.
A MempoolAPIController binds http requests to an api service and writes the service results to the http response.
A NetworkAPIController binds http requests to an api service and writes the service results to the http response.
A Route defines the parameters for an api endpoint.
A SearchAPIController binds http requests to an api service and writes the service results to the http response.

# Interfaces

AccountAPIRouter defines the required methods for binding the api requests to a responses for the AccountAPI The AccountAPIRouter implementation should parse necessary information from the http request, pass the data to a AccountAPIServicer to perform the required actions, then write the service results to the http response.
AccountAPIServicer defines the api actions for the AccountAPI service This interface intended to stay up to date with the openapi yaml used to generate it, while the service implementation can ignored with the .openapi-generator-ignore file and updated with the logic required for the API.
BlockAPIRouter defines the required methods for binding the api requests to a responses for the BlockAPI The BlockAPIRouter implementation should parse necessary information from the http request, pass the data to a BlockAPIServicer to perform the required actions, then write the service results to the http response.
BlockAPIServicer defines the api actions for the BlockAPI service This interface intended to stay up to date with the openapi yaml used to generate it, while the service implementation can ignored with the .openapi-generator-ignore file and updated with the logic required for the API.
CallAPIRouter defines the required methods for binding the api requests to a responses for the CallAPI The CallAPIRouter implementation should parse necessary information from the http request, pass the data to a CallAPIServicer to perform the required actions, then write the service results to the http response.
CallAPIServicer defines the api actions for the CallAPI service This interface intended to stay up to date with the openapi yaml used to generate it, while the service implementation can ignored with the .openapi-generator-ignore file and updated with the logic required for the API.
ConstructionAPIRouter defines the required methods for binding the api requests to a responses for the ConstructionAPI The ConstructionAPIRouter implementation should parse necessary information from the http request, pass the data to a ConstructionAPIServicer to perform the required actions, then write the service results to the http response.
ConstructionAPIServicer defines the api actions for the ConstructionAPI service This interface intended to stay up to date with the openapi yaml used to generate it, while the service implementation can ignored with the .openapi-generator-ignore file and updated with the logic required for the API.
EventsAPIRouter defines the required methods for binding the api requests to a responses for the EventsAPI The EventsAPIRouter implementation should parse necessary information from the http request, pass the data to a EventsAPIServicer to perform the required actions, then write the service results to the http response.
EventsAPIServicer defines the api actions for the EventsAPI service This interface intended to stay up to date with the openapi yaml used to generate it, while the service implementation can ignored with the .openapi-generator-ignore file and updated with the logic required for the API.
MempoolAPIRouter defines the required methods for binding the api requests to a responses for the MempoolAPI The MempoolAPIRouter implementation should parse necessary information from the http request, pass the data to a MempoolAPIServicer to perform the required actions, then write the service results to the http response.
MempoolAPIServicer defines the api actions for the MempoolAPI service This interface intended to stay up to date with the openapi yaml used to generate it, while the service implementation can ignored with the .openapi-generator-ignore file and updated with the logic required for the API.
NetworkAPIRouter defines the required methods for binding the api requests to a responses for the NetworkAPI The NetworkAPIRouter implementation should parse necessary information from the http request, pass the data to a NetworkAPIServicer to perform the required actions, then write the service results to the http response.
NetworkAPIServicer defines the api actions for the NetworkAPI service This interface intended to stay up to date with the openapi yaml used to generate it, while the service implementation can ignored with the .openapi-generator-ignore file and updated with the logic required for the API.
Router defines the required methods for retrieving api routes.
SearchAPIRouter defines the required methods for binding the api requests to a responses for the SearchAPI The SearchAPIRouter implementation should parse necessary information from the http request, pass the data to a SearchAPIServicer to perform the required actions, then write the service results to the http response.
SearchAPIServicer defines the api actions for the SearchAPI service This interface intended to stay up to date with the openapi yaml used to generate it, while the service implementation can ignored with the .openapi-generator-ignore file and updated with the logic required for the API.

# Type aliases

Routes are a collection of defined api endpoints.