mirror of https://github.com/knative/client.git
bumping golang.org/x/oauth2 ebe81ad...85231f9:
> 85231f9 go.mod: update golang.org/x dependencies
> 34a7afa google/externalaccount: add Config.UniverseDomain
> 95bec95 google/externalaccount: moves externalaccount package out of internal and exports it
bumping google.golang.org/genproto/googleapis/rpc 1f4bbc5...37d4d3c:
> 37d4d3c chore(all): update all (# 1089)
> df926f6 chore(all): auto-regenerate .pb.go files (# 1092)
> 05fd2b7 chore(all): Update to google.golang.org/genproto/googleapis/rpc without backreference (# 1093)
> 1f18d85 chore(all): Drop submodule backreferences (# 1087)
> 6ceb2ff chore: make vet script less error prone (# 1091)
> c5ed0a4 chore(all): auto-regenerate .pb.go files (# 1084)
> 9b9be74 chore: updates for Go 1.22 (# 1090)
> b0ce06b chore(all): update all (# 1088)
> 012b6fc chore(all): update all (# 1086)
> 31a09d3 chore(all): update all (# 1085)
bumping k8s.io/klog/v2 6ded808...007e661:
> 007e661 textlogger: allow caller to override stack unwinding
> 2d08296 Merge pull request # 396 from pohly/slog-helper
> 2086216 Merge pull request # 393 from kaisoz/add-safeptr
> e4deee8 slog: use main logr package instead of logr/slogr
> 8dd3f2e Merge pull request # 395 from pohly/readme-update
> 881fa0b Add SafePtr wrapper
> 5d1d2d5 add SetSlogLogger
> 761b630 Merge pull request # 394 from pohly/owners-update
> d3dd725 docs: clarify relationship between different features
> e3f75b8 Merge pull request # 384 from pohly/slog
> 39afdba dependencies: logr v1.4.1
> f33bd6c OWNERS: remove serathius, add mengjiao-liu, promote pohly
> 02e7b69 Merge pull request # 391 from pohly/with-name-output
> 44eadc3 add slog support
> b588475 Merge pull request # 380 from pohly/golangci-lint-action
> 009a04a output: handle WithName like zapr does
> cc856bb update to logr 1.3.0
> edee20c Merge pull request # 392 from pohly/promote-experimental
> 1a0dfc5 github: run golangci-lint via action
> 61b308a Merge pull request # 390 from pohly/go-vet-print
> 18cdd3a promote experimental code to stable
> ef25537 fix revive issues
> 6632ba5 Merge pull request # 376 from pohly/stderr-threshold-docs
> 6af4ad1 testing: bump Go version matrix
> a4f9060 fix golangci-lint issues
> ff82b97 Merge pull request # 379 from lowang-bh/fixWarning
> 3838dbc stderrthreshold: fix flag comment
> b394f4b enable "go vet" checks for parameters
> 5ac9b76 Merge pull request # 378 from aimuz/fix-370
> 6c35c6a resolve comments warning
> 1e2789b fix: SetLogger via klog.SetLogger will output an unexpected newline
bumping knative.dev/client-pkg 2c46c44...ca457df:
> ca457df upgrade to latest dependencies (# 154)
> f170971 🎁 Terminal UI basic implementation (# 139)
> ae3b852 [main] Upgrade to latest dependencies (# 146)
> e7f1f8d Update community files (# 151)
bumping golang.org/x/term 353276a...c5eaf76:
> c5eaf76 go.mod: update golang.org/x dependencies
bumping google.golang.org/api 87aa1d0...9c2cde8:
> 9c2cde8 chore(main): release 0.169.0 (# 2451)
> a488112 feat(all): auto-regenerate discovery clients (# 2457)
> 2675c0a feat(all): auto-regenerate discovery clients (# 2454)
> d22da18 feat(all): auto-regenerate discovery clients (# 2450)
> e84ba36 chore(main): release 0.168.0 (# 2432)
> 74538f7 chore(all): update module github.com/google/go-github/v58 to v59 (# 2411)
> 6381123 chore(all): update all (# 2435)
> b438981 feat(all): auto-regenerate discovery clients (# 2449)
> af383c7 feat(all): auto-regenerate discovery clients (# 2448)
> 022c85c feat(all): auto-regenerate discovery clients (# 2447)
> 4fa90c9 feat(all): auto-regenerate discovery clients (# 2445)
> ced0c09 feat(all): auto-regenerate discovery clients (# 2443)
> 9f9c0cf feat(all): auto-regenerate discovery clients (# 2442)
> 454cba5 chore: make vet script less error prone (# 2441)
>
|
||
|---|---|---|
| .. | ||
| log | ||
| .gitignore | ||
| .goconvey | ||
| .travis.yml | ||
| CHANGES.md | ||
| LICENSE | ||
| Makefile | ||
| README.md | ||
| SECURITY.md | ||
| Srcfile | ||
| bench_test.sh | ||
| compress.go | ||
| compressor_cache.go | ||
| compressor_pools.go | ||
| compressors.go | ||
| constants.go | ||
| container.go | ||
| cors_filter.go | ||
| coverage.sh | ||
| curly.go | ||
| curly_route.go | ||
| custom_verb.go | ||
| doc.go | ||
| entity_accessors.go | ||
| extensions.go | ||
| filter.go | ||
| filter_adapter.go | ||
| json.go | ||
| jsoniter.go | ||
| jsr311.go | ||
| logger.go | ||
| mime.go | ||
| options_filter.go | ||
| parameter.go | ||
| path_expression.go | ||
| path_processor.go | ||
| request.go | ||
| response.go | ||
| route.go | ||
| route_builder.go | ||
| route_reader.go | ||
| router.go | ||
| service_error.go | ||
| web_service.go | ||
| web_service_container.go | ||
README.md
go-restful
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:
- GET = Retrieve a representation of a resource
- POST = Create if you are sending content to the server to create a subordinate of the specified resource collection, using some server-side algorithm.
- PUT = Create if you are sending the full content of the specified resource (URI).
- PUT = Update if you are updating the full content of the specified resource.
- DELETE = Delete if you are requesting the server to delete the resource
- PATCH = Update partial content of a resource
- OPTIONS = Get information about the communication options for the request URI
Usage
Without Go Modules
All versions up to v2.*.* (on the master) are not supporting Go modules.
import (
restful "github.com/emicklei/go-restful"
)
Using Go Modules
As of version v3.0.0 (on the v3 branch), this package supports Go modules.
import (
restful "github.com/emicklei/go-restful/v3"
)
Example
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")
...
}
Features
- Routes for request → function mapping with path parameter (e.g. {id} but also prefix_{var} and {var}_suffix) support
- Configurable router:
- (default) Fast routing algorithm that allows static elements, google custom method, regular expressions and dynamic parameters in the URL path (e.g. /resource/name:customVerb, /meetings/{id} or /static/{subpath:*})
- Routing algorithm after JSR311 that is implemented using (but does not accept) regular expressions
- Request API for reading structs from JSON/XML and accessing parameters (path,query,header)
- Response API for writing structs to JSON/XML and setting headers
- Customizable encoding using EntityReaderWriter registration
- Filters for intercepting the request → response flow on Service or Route level
- Request-scoped variables using attributes
- Containers for WebServices on different HTTP endpoints
- Content encoding (gzip,deflate) of request and response payloads
- Automatic responses on OPTIONS (using a filter)
- Automatic CORS request handling (using a filter)
- API declaration for Swagger UI (go-restful-openapi)
- Panic recovery to produce HTTP 500, customizable using RecoverHandler(...)
- Route errors produce HTTP 404/405/406/415 errors, customizable using ServiceErrorHandler(...)
- Configurable (trace) logging
- Customizable gzip/deflate readers and writers using CompressorProvider registration
- Inject your own http.Handler using the
HttpMiddlewareHandlerToFilterfunction
How to customize
There are several hooks to customize the behavior of the go-restful package.
- Router algorithm
- Panic recovery
- JSON decoder
- Trace logging
- Compression
- Encoders for other serializers
- Use jsoniter by building this package using a build tag, e.g.
go build -tags=jsoniter . - Use the package variable
TrimRightSlashEnabled(default true) to control the behavior of matching routes that end with a slash/
Resources
- Example programs
- Example posted on blog
- Design explained on blog
- sourcegraph
- showcase: Zazkia - tcp proxy for testing resiliency
- showcase: Mora - MongoDB REST Api server
Type git shortlog -s for a full list of contributors.
© 2012 - 2023, http://ernestmicklei.com. MIT License. Contributions are welcome.
