Skip to content
/ rest Public

Package rest it's tiny lightweight package which helps to work with RESTful API and JSON API.

License

Notifications You must be signed in to change notification settings

thepkg/rest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rest

CircleCI Go Report Card godoc

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

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

About

Package rest it's tiny lightweight package which helps to work with RESTful API and JSON API.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages