package for building REST-style Web Services using Google Go
REST asks developers to use HTTP methods explicitly and in a way that's consistent with the protocol definition. This basic REST design principle establishes a one-to-one mapping between create, read, update, and delete (CRUD) operations and HTTP methods. According to this mapping:
All versions up to v2.*.* (on the master) are not supporting Go modules.
import (
restful "github.com/emicklei/go-restful"
)
As of version v3.0.0 (on the v3 branch), this package supports Go modules.
import (
restful "github.com/emicklei/go-restful/v3"
)
ws := new(restful.WebService)
ws.
Path("/users").
Consumes(restful.MIME_XML, restful.MIME_JSON).
Produces(restful.MIME_JSON, restful.MIME_XML)
ws.Route(ws.GET("/{user-id}").To(u.findUser).
Doc("get a user").
Param(ws.PathParameter("user-id", "identifier of the user").DataType("string")).
Writes(User{}))
...
func (u UserResource) findUser(request *restful.Request, response *restful.Response) {
id := request.PathParameter("user-id")
...
}
HttpMiddlewareHandlerToFilter functionSetPathTokenCacheEnabled and SetCustomVerbCacheEnabled to disable regexp caching (default=true)There are several hooks to customize the behavior of the go-restful package.
TrimRightSlashEnabled (default true) to control the behavior of matching routes that end with a slash /Type git shortlog -s for a full list of contributors.
© 2012 - 2023, http://ernestmicklei.com. MIT License. Contributions are welcome.
(top 30 of 91)
Go
99.8%
package for building REST-style Web Services using Google Go
REST asks developers to use HTTP methods explicitly and in a way that's consistent with the protocol definition. This basic REST design principle establishes a one-to-one mapping between create, read, update, and delete (CRUD) operations and HTTP methods. According to this mapping:
All versions up to v2.*.* (on the master) are not supporting Go modules.
import (
restful "github.com/emicklei/go-restful"
)
As of version v3.0.0 (on the v3 branch), this package supports Go modules.
import (
restful "github.com/emicklei/go-restful/v3"
)
ws := new(restful.WebService)
ws.
Path("/users").
Consumes(restful.MIME_XML, restful.MIME_JSON).
Produces(restful.MIME_JSON, restful.MIME_XML)
ws.Route(ws.GET("/{user-id}").To(u.findUser).
Doc("get a user").
Param(ws.PathParameter("user-id", "identifier of the user").DataType("string")).
Writes(User{}))
...
func (u UserResource) findUser(request *restful.Request, response *restful.Response) {
id := request.PathParameter("user-id")
...
}
HttpMiddlewareHandlerToFilter functionSetPathTokenCacheEnabled and SetCustomVerbCacheEnabled to disable regexp caching (default=true)There are several hooks to customize the behavior of the go-restful package.
TrimRightSlashEnabled (default true) to control the behavior of matching routes that end with a slash /Type git shortlog -s for a full list of contributors.
© 2012 - 2023, http://ernestmicklei.com. MIT License. Contributions are welcome.
(top 30 of 91)
Go
99.8%