go-footing

command module
v0.0.0-...-f57aad6 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2022 License: MIT Imports: 1 Imported by: 0

README

Go Restful API Boilerplate

Easily extendable RESTful API footing.

The goal of this footing is to have a solid and structured foundation to build upon on.

Features

The following feature set is a minimal selection of typical Web API requirements:

  • Configuration using viper
  • CLI features using cobra
  • PostgreSQL support using gorm
  • Logging with zap
  • Routing with fiber and middlewares
  • JWT Authentication using jwt-go

Start Application

  • Clone this repository
git clone https://github.com/krushev/go-footing.git && cd go-footing
  • Create a postgres database and add all required variables for your database in the config accordingly if not using same as default
sudo su postgres

psql -U postgres -c "CREATE USER footing WITH PASSWORD 'footing'"
psql -U postgres -c "CREATE DATABASE footing"
psql -U postgres -c "ALTER DATABASE footing OWNER TO footing"
psql -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE footing to footing"
  • Run the application to see available commands: go run main.go
  • Run the application with command serve: go run main.go serve
RESTful API

Login

curl -X POST 'http://localhost:3000/api/login' -d '{"username": "admin@host.xyz", "password": "admin"}'

Access users

curl -X GET 'http://localhost:3000/api/v0.0.1/users' -H "Authorization: Bearer PUT_RECEIVED_TOKEN"
curl -X GET 'http://localhost:3000/api/v0.0.1/users/2' -H "Authorization: Bearer PUT_RECEIVED_TOKEN"
curl -X GET 'http://localhost:3000/api/v0.0.1/users/search?q=user' -H "Authorization: Bearer PUT_RECEIVED_TOKEN"

Refresh token

curl -X POST 'http://localhost:3000/api/refresh' -H "Authorization: Bearer PUT_RECIEVED_TOKEN"
Client API Access

Use one of the following bootstrapped users for login:

Config Variables

By default, viper will look first at current folder for footing.yaml and second at $HOME/.footing.yaml for a config file.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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