boltapi

package module
v0.0.0-...-08e351d Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2015 License: MIT Imports: 8 Imported by: 0

README

BoltDB REST API GoDoc

Adds restful API on top of BoltDB.

Building

  1. Install gpm
  2. Install dependencies:
$ git clone https://github.com/marconi/boltapi && cd boltapi
$ gpm
$ make build && make install
Running
$ boltapi -dbpath=./app.db

You can change what port the API listens with -port param.

Endpoints

Exposes the following endpoints:

Buckets endpoint

/api/v1/buckets

GET  - List buckets
POST - Add bucket

Bucket endpoint

/api/v1/buckets/<name>

GET    - List bucket items
POST   - Add item on the bucket
DELETE - Delete bucket

Bucket item endpoint

/api/v1/buckets/<name>/<key>

GET    - Retrieve item
PUT    - Update item
DELETE - Delete item

You can also check the tests for sample usage of these endpoints.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBucketList        = errors.New("error listing buckets")
	ErrBucketGet         = errors.New("error retrieving bucket")
	ErrBucketMissing     = errors.New("bucket doesn't exist")
	ErrBucketCreate      = errors.New("error creating bucket")
	ErrBucketDelete      = errors.New("error deleting bucket")
	ErrBucketDecodeName  = errors.New("error reading bucket name")
	ErrBucketInvalidName = errors.New("invalid bucket name")
	ErrBucketItemDecode  = errors.New("error reading bucket item")
	ErrBucketItemEncode  = errors.New("error encoding bucket item")
	ErrBucketItemCreate  = errors.New("error creating bucket item")
	ErrBucketItemUpdate  = errors.New("error updating bucket item")
	ErrBucketItemDelete  = errors.New("error deleting bucket item")
)

Functions

func Serve

func Serve(db *bolt.DB, port int) error

Types

type ApiError

type ApiError struct {
	// contains filtered or unexported fields
}

func (ApiError) Error

func (err ApiError) Error() string

type BucketItem

type BucketItem struct {
	Key   string
	Value interface{}
}

func (*BucketItem) DecodeValue

func (item *BucketItem) DecodeValue(rawValue []byte) error

func (*BucketItem) EncodeKey

func (item *BucketItem) EncodeKey() []byte

func (*BucketItem) EncodeValue

func (item *BucketItem) EncodeValue() ([]byte, error)

type RestApi

type RestApi struct {
	// contains filtered or unexported fields
}

func NewRestApi

func NewRestApi(db *bolt.DB) (*RestApi, error)

func (*RestApi) AddBucket

func (restapi *RestApi) AddBucket(w rest.ResponseWriter, r *rest.Request)

func (*RestApi) AddBucketItem

func (restapi *RestApi) AddBucketItem(w rest.ResponseWriter, r *rest.Request)

func (*RestApi) DeleteBucket

func (restapi *RestApi) DeleteBucket(w rest.ResponseWriter, r *rest.Request)

func (*RestApi) DeleteBucketItem

func (restapi *RestApi) DeleteBucketItem(w rest.ResponseWriter, r *rest.Request)

func (*RestApi) GetBucket

func (restapi *RestApi) GetBucket(w rest.ResponseWriter, r *rest.Request)

func (*RestApi) GetBucketItem

func (restapi *RestApi) GetBucketItem(w rest.ResponseWriter, r *rest.Request)

func (*RestApi) GetHandler

func (restapi *RestApi) GetHandler() http.Handler

func (*RestApi) ListBuckets

func (restapi *RestApi) ListBuckets(w rest.ResponseWriter, r *rest.Request)

func (*RestApi) UpdateBucketItem

func (restapi *RestApi) UpdateBucketItem(w rest.ResponseWriter, r *rest.Request)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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