Package rest
it's tiny lightweight package which helps to work with RESTful API and JSON API.
go get -u github.com/thepkg/rest
import "github.com/thepkg/rest"
func main() {
rest.GET("/users", func(w http.ResponseWriter, r *http.Request) {
rest.Success(w, http.StatusOK, "find")
})
rest.POST("/users", func(w http.ResponseWriter, r *http.Request) {
rest.Success(w, http.StatusOK, "create")
})
rest.PUT("/users", func(w http.ResponseWriter, r *http.Request) {
rest.Error(w, http.StatusMethodNotAllowed, "update not allowed")
})
rest.DELETE("/users", func(w http.ResponseWriter, r *http.Request) {
rest.Error(w, http.StatusMethodNotAllowed, "delete not allowed")
})
http.ListenAndServe(":8080", nil)
}