Tiny REST framework for Go
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
.travis.yml
AUTHORS.md
Makefile
README.md
core.go
core_test.go

README.md

Sloth

A tiny REST framework for Go

Sloth is a micro-framework for building RESTful APIs. It was forked from Sleepy to support the Gorilla web toolkit.

Build Status

package main

import (
    "net/http"
    "github.com/strukturag/sloth"
)

type Item struct {}

func (item Item) Get(request *http.Request) (int, interface{}, http.Header) {
    items := []string{"item1", "item2"}
    data := map[string][]string{"items": items}
    return 200, data, http.Header{"Content-type": {"application/json"}}
}

func main() {
    item := new(Item)

    api := sloth.NewAPI()
    api.AddResource(item, "/items")
    api.Start(3000)
}

Now if we curl that endpoint:

$ curl localhost:3000/items
{
  "items": [
    "item1",
    "item2"
  ]
}

Docs

Documentation lives here.

License

Sloth is released under the MIT License.