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)
}