This repository is archived. While it still may hold useful pieces of code within it, it is old and out of date.
This is a project to help you get up an running fast with a secure, light weight, extensible api structure.
Intermediate This project gives you a basic structure to work with.
- Docker
- Secret Key Generation and handling (for JWT's)
- MySQL
- Built in load balancer
- MC (MVC with out the view) esc structure
- Request logging to NoSql DynamoDB
- JWT Generation for user authentication
Routing in the API takes a slightly different approach from an MVC architecture. Step by step:
- Initial Request: Request comes in and a
handler
is found that maps to the base request. Seemain.go
's routes. - Handlers: The handler registers it's own routes and passes them to a routing function that parses the path and determines which callback function to call.
- Handler Functions: The called handler function instantiates the proper
record
and calls the associated functions and returns the resulting response. - Records: A Record is a representation of a database table in the form a struct. It holds all the necessary Queries.
- Connection: A connection is a connection to a data source.
The api is set up to log requests to a dynamodb on AWS. You must supply the proper credentails for the api to connect to the service.
See amazons credential documentation. You can comment out where the log is pushed to the log channel in the RouteController
function in the handler.go
file if you want to disable logging.
If you need to generate a key for your server: run the script in the templates folder in the docker folder, that will generate a byte key that will then be copied to the docker container and be used for generating jwt's and hashing passwords.
Verbose can be turned off in the Dockerfile under API_VERBOSE. Verbose will print err's and stack traces when set in the api response.
Feel free to open any and all pull requests. :D