go-api

module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2019 License: MIT

README

go-api

go-api is a simple example API with support for common implementations

Build Status Report Codacy Badge Release standard-readme compliant GoDoc

Table of Contents

Installation

Prerequisite Applications:
  1. go-api requires a supported release of Go and dep.
$ go get -u github.com/mrz1836/go-api
$ go get -u github.com/pressly/goose/cmd/goose
$ go get -u -t github.com/volatiletech/sqlboiler
$ go get -u github.com/volatiletech/sqlboiler/drivers/sqlboiler-mysql
  1. Set your environment variables (or add to your bash profile):
$ cd ../go-api
$ . scripts/set_env.sh
  1. Setup a fresh database (if you don't have one already)
$ . scripts/setup_db.sh
  1. Run the API!
$ go run cmd/application/main.go

    starting Go API server...

Test your connection to go-api

$ curl -X GET 'http://localhost:3000'

  Welcome to the Go API!
Managing Dependencies

Updating dependencies in go-api:

$ cd ../go-api
$ dep ensure -update -v
Managing Environment Variables

All environment variables are referenced in the config.

Edit the scripts/set_env.sh file and modify the environment variables - IE:

export API_SERVER_PORT=3000
Managing Model Generation

Update the reset_api_database.sql if you have issues running the model tests

GRANT ALL ON `dynamic-database-name-generated-from-sql-boiler`.* to 'apiDbTestUser'@'%';

Rebuilding the generated models/schema from the database schema:

$ cd ../go-api
$ . scripts/rebuild_models.sh

Clear local redis and reload the database

$ . scripts/setup_db.sh && . scripts/flush_redis.sh
Package Dependencies

Documentation

You can view the generated documentation here.

Features
  • Combination of powerful Go packages all-in-one API solution
  • The fastest router: Julien Schmidt's httprouter
  • The best redis cache package: Gary Burd's Redigo
  • Powerful database ORM: VolatileTech's SQLBoiler
  • Database migration: Pressly's Goose
  • Ready for development or production use
  • Cache dependency management via go-cache
  • Supports different incoming load balancer setups (/health)
  • Logging each request and whenever you need logs (remote via LogEntries)
  • Flexible environment & configuration management using viper
  • Built-in scheduler for any cron jobs or delayed tasks
  • Powerful and easy emailing with support for Postmark, Mandrill, AWS SES and SMTP

Examples & Tests

All unit tests and examples run via Travis CI and uses Go version 1.13.x. View the deployment configuration file.

Run all tests (including integration tests)

$ cd ../go-api
$ go test ./... -v

Run tests (excluding integration tests)

$ cd ../go-api
$ go test ./... -v -test.short

View and run the examples:

$ cd ../go-api/examples
$ go run examples.go

Benchmarks

Run the Go benchmarks:

$ cd ../go-api
$ go test -bench . -benchmem

Code Standards

Read more about this Go project's code standards.

Usage

View the examples

Maintainers

@MrZ

Contributing

View the contributing guidelines and follow the code of conduct.

Support the development of this project 🙏

Donate

License

License

Directories

Path Synopsis
actions
base_api
Package baseapi is all the base requests and router configuration
Package baseapi is all the base requests and router configuration
persons
Package persons are the actions associated with the person model
Package persons are the actions associated with the person model
cmd
application command
Package main is the main application
Package main is the main application
Package config provides a configuration for the API
Package config provides a configuration for the API
Package database provides a layer for interacting with read/write databases
Package database provides a layer for interacting with read/write databases
Package jobs is for all scheduled jobs (tasks) to run
Package jobs is for all scheduled jobs (tasks) to run
Package models extends the schema package for model management
Package models extends the schema package for model management
Package notifications handles all outbound notifications (email, sms, push, etc)
Package notifications handles all outbound notifications (email, sms, push, etc)
Package router is all the restful handler/router endpoint and methods for the application
Package router is all the restful handler/router endpoint and methods for the application

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL