golang_api_boilerplate

command module
v0.0.0-...-650db0a Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2021 License: BSD-3-Clause Imports: 17 Imported by: 0

README

Go API example with JWT auth

Boiler plate code for APIs protected by username/login and javascript web token with a 10 minute expiry time.

Deploy Go Report Card

Companion app, which provides the UI for this API server

Features

  • New users get saved to Postgres.
  • Set Env Var NEEDS_AUTH=yes on Heroku for auth
  • If you want auth also set TOKEN_PASSWORD=yourlongsecretkeyhere so you can generate tokens

Endpoints:

  1. api/user/login
  2. api/user/new
  3. api/quote

The login and new take a JSON payload of {"email": "valar@morghulis.com", "password": "valardohaeris"}

While quote requires an Authorisation Header with the Bearer token issued by user creation or log in (if NEEDS_AUTH == yes)

This repo is heavily based on Adigun Olalekan's excellent post here: https://medium.com/@adigunhammedolalekan/build-and-deploy-a-secure-rest-api-with-go-postgresql-jwt-and-gorm-6fadf3da505b

again...

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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