Skip to content

daetal-us/grotto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grotto

A naive HTTP JSON API for Postgres

Minimally-configurable, REST-like interaction with a postgres database.

Installation

go get github.com/daetal-us/grotto

Requirements

  • Requires Go.
  • Requires an accessible instance of Postgres.
  • Only table names containing alphanumeric, dashes and underscore characters will be accessible.
  • Primary key columns for all tables assumed to be id.

Usage

grotto -addr :8080 -dsn postgres://user:password@host/db

Interface

The interface consists of standard HTTP request methods paired with the following path conventions:

path description GET (read) POST (create) PUT (update) DELETE
/ all available tables
/:table all rows in table
/:table/:id specific row in table

Responses

All rows in hypothetical users table:

GET /users HTTP/1.1
...
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
...
{
  "data": [
    {
      ...
    },
    ...
  ]
}

Single row in hypothetical users table:

GET /users/1234 HTTP/1.1
...
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
...
{
  "data": {
    "id": 1234,
    ...
  }
}

Table not found:

GET /nonexistant-table HTTP/1.1
...
HTTP/1.1 404 Not Found
Content-Type: application/json; charset=UTF-8
...
{
  "error": "Table not found."
}

About

A naive HTTP JSON API for use with Postgres.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages