Giter Site home page Giter Site logo

Rest

ci codecov docker chat

Rest serves a fully RESTful API from any SQL database, PostgreSQL, MySQL, and SQLite are supported for now.

Visit https://rest-go.com for the full documentation, examples, and guides.

Getting Started

Start with Docker

run the server and connect to an existing database

# connect to postgres
docker run -p 3000:3000 restgo/rest -db.url "postgres://user:passwd@localhost:5432/db"

# connect to sqlite file with volume
docker run -p 3000:3000 -v $(pwd):/data restgo/rest -db.url "sqlite:///data/my.db"

Use API

Assume there is a todos table in the database with id, and title fields:

# Create a todo item
curl -XPOST "localhost:3000/todos" -d '{"title": "setup api server", "done": false}'

# Read
curl -XGET "localhost:3000/todos/1"

# Update
curl -XPUT "localhost:3000/todos/1" -d '{"title": "setup api server", "done": true}'

# Delete
curl -XDELETE "localhost:3000/todos/1"

Use the binary

Precompiled binaries

Precompiled binaries for released versions are available on the Releases page, download it to your local machine, and running it directly is the fastest way to use Rest.

Go install

If you are familiar with Golang, you can use go install

go install github.com/rest-go/rest

Run server

rest -db.url "mysql://username:password@tcp(localhost:3306)/db"

Use it as a Go library

It also works to embed the rest server into an existing Go HTTP server

go get github.com/rest-go/rest
package main

import (
	"log"
	"net/http"

	"github.com/rest-go/rest/pkg/server"
)

func main() {
	h := server.New(&server.DBConfig{URL: "sqlite://my.db"}, server.Prefix("/admin"))
	http.Handle("/admin/", h)
	log.Fatal(http.ListenAndServe(":3001", nil))
}

Rest's Projects

auth icon auth

RESTFul Authentication and Authorization package for Golang app

rest icon rest

Rest serves a fully RESTful API from any SQL database

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.