Skip to content
Simplest API Server
Go
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
Dockerfile
LICENSE
README.md
config.go
config_test.go
main.go
method.go
query.go
sample.yml

README.md

miq

Docker Build Statu CircleCI Go Report Card

Create API server with RDB from few lines of YAML.

Description

miq is simple API server defined by YAML file. It's connected with your favorite RDB, runs SQL queries and returns the result as JSON response.

This approach is inspired by Microservices. This is for only internal, not for public server(Authentification is not supported).

Demo

You can try Sample with Docker immediately!

Usage

db:
  driver: sqlite3
  filepath: test.db
rules:
  - path: /show/:id/
    query: SELECT * FROM test WHERE id = {{id}};
  - path: /showall/
    query: SELECT * FROM test;
  - path: /create/
    query: INSERT INTO test (body) VALUES ({{body}});

Go /show/3, and you can get {"success":true,"rows":[{ ... ,"id":3}]} or something like this.

Or you can give variables as URL query or request body(JSON). For example, request /create?body='abc' and a record is inserted.

To start server, run

$ miq sample.yml

Requirement

  • Go
  • RDB(sqlite3 and mysql are currently supported)

Install

$ go get github.com/acomagu/miq

Author

acomagu

You can’t perform that action at this time.