This package and subpackages implement the HTTP API Server for the Flow OpenAPI definition. The API documentation is available on our docs site.
rest
: The HTTP handlers for all the request, server generator and the select filter.middleware
: The common middlewares that all request pass through.models
: The generated models using openapi generators and implementation of model builders.request
: Implementation of API requests that provide validation for input data and build request models.
- Every incoming request passes through a common set of middlewares - logging middleware, query expandable and query select middleware defined in the middleware package.
- Each request is then wrapped by our handler (
rest/handler.go
) and request input data is used to build the request models defined in request package. - The request is then sent to the corresponding API handler based on the configuration in the router.
- Each handler implements actions to perform the request (database lookups etc) and after the response is built using the model builders defined in models package.
- Returned value is then again handled by our wrapped handler making sure to correctly handle successful and failure responses.
Make sure the OpenAPI schema if first updated and merged into master on the hosted repository. After you can use the make command to generated updated models:
make generate-openapi
A new endpoint can be added by first implementing a new request handler, a request handle is a function in the rest package that complies with function interfaced defined as:
type ApiHandlerFunc func (
r *request.Request,
backend access.API,
generator models.LinkGenerator,
) (interface{}, error)
That handler implementation needs to be added to the router.go
with corresponding API endpoint and method. Adding a
new API endpoint also requires for a new request builder to be implemented and added in request package. Make sure to
not forget about adding tests for each of the API handler.