https://github.com/thepkg/rest
Package rest it's tiny lightweight package which helps to work with RESTful API and JSON API.
https://github.com/thepkg/rest
go golang http json-api rest
Last synced: 25 days ago
JSON representation
Package rest it's tiny lightweight package which helps to work with RESTful API and JSON API.
- Host: GitHub
- URL: https://github.com/thepkg/rest
- Owner: thepkg
- License: mit
- Created: 2018-08-06T21:36:54.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-11-18T17:47:08.000Z (over 6 years ago)
- Last Synced: 2025-12-18T22:10:37.566Z (6 months ago)
- Topics: go, golang, http, json-api, rest
- Language: Go
- Homepage: https://godoc.org/github.com/thepkg/rest
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
rest
-
[](https://circleci.com/gh/thepkg/rest)
[](https://goreportcard.com/report/github.com/thepkg/rest)
[](https://godoc.org/github.com/thepkg/rest)
Package `rest` it's tiny lightweight package which helps to work with RESTful API and JSON API.
## Installation
`go get -u github.com/thepkg/rest`
## Usage
````go
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)
}
````