diygoapi

module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2017 License: MIT

README

go-API-template

An attempt at creating a RESTful API template (built with Go).

  • I'm learning Go as a hobby currently (started in January 2017) and absolutely love it. I'm hoping to start to use Go professionally soon and in order to do so, I want to make sure I'm able to build "industrial strength" REST APIs, in order to mentor my team. The goal of this app is to make an example/template of relational database-backed APIs that have characteristics needed to ensure success in a high volume environment. This is a work in progress - you'll notice most things below are not checked, but I will get there! Any feedback and/or support are welcome. I'm not an expert and have very thick skin, so please feel free to tell me how bad something is and I'll make it better.

Critical components of any API (in no particular order)

  • Unit Testing (with reasonably high coverage %)
  • Verbose Code Documentation
  • Instrumentation
    • request/response logging (ability to turn on and off logging type based on some type of flag)
      • logStyle 1: structured (JSON), leveled (debug, error, info, etc.) logging to stdout
      • logStyle 2: relational database logging (certain data points broken out into standard column datatypes, request/response stored in TEXT/CLOB datatype columns)
      • API Metrics
      • Performance Monitoring
      • Helpful debug logging
  • Fault tolerant - Proper Error Raising/Handling
  • RESTful service versioning
  • Security/Authentication/Authorization using HTTPS/OAuth2, etc.
  • Properly Vendored dependencies (I have no idea how to do this yet...)
  • Containerized
  • Generated Client examples
  • Extensive API Documentation for Clients of the API (see twilio, Uber, Stripe and mailchimp as good examples)

Helpful Resources I've used in this app

  • JustforFunc
  • Go By Example
  • Mat Ryer

Release roadmap below is to help me stay on track. With my ADD brain, I often lose focus...

Items to complete for Release 0.0.1

  • Add unique Request-ID to response headers using util
  • Document code better

Items to complete for Release 0.0.2

  • Relational DB Request logging

Items to complete for Release 0.0.3

  • Response JSON logging and httputil.DumpResponse

Items to complete for Release 0.0.4

Directories

Path Synopsis
cmd
appUser command
Allows for testing the different flows without having to go through the http server
Allows for testing the different flows without having to go through the http server
appUser/client command
appUser/server command
pkg
appUser
Package appUser has the User type and associated methods to create, modify and delete application users
Package appUser has the User type and associated methods to create, modify and delete application users
client
Package client package sets up clients for calling the APIs in this app approach largely taken from Marcus Olsson
Package client package sets up clients for calling the APIs in this app approach largely taken from Marcus Olsson
config/env
Package env has a type to store common environment related items sql db, logger, etc.
Package env has a type to store common environment related items sql db, logger, etc.

Jump to

Keyboard shortcuts

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