update package dependencies (#5463)
Signed-off-by: fsl <1171313930@qq.com> Signed-off-by: fsl <1171313930@qq.com>
This commit is contained in:
17
vendor/github.com/emicklei/go-restful/CHANGES.md
generated
vendored
17
vendor/github.com/emicklei/go-restful/CHANGES.md
generated
vendored
@@ -1,21 +1,28 @@
|
||||
# Change history of go-restful
|
||||
# Change history of go-restful (v2 only)
|
||||
|
||||
## v2.16.0 - 2022-07-11
|
||||
|
||||
## [v2.14.3] - 2020-08-31
|
||||
- Backported CORS filter. #489 (#493) #503
|
||||
|
||||
## v2.15.0 - 2020-11-10
|
||||
|
||||
- Add OPTIONS in Webservice
|
||||
|
||||
## v2.14.3 - 2020-08-31
|
||||
- Fixed duplicate compression in dispatch. #449
|
||||
|
||||
|
||||
## [v2.14.2] - 2020-08-31
|
||||
## v2.14.2 - 2020-08-31
|
||||
|
||||
- Added check on writer to prevent compression of response twice. #447
|
||||
|
||||
## [v2.14.0] - 2020-08-19
|
||||
## v2.14.0 - 2020-08-19
|
||||
|
||||
- Enable content encoding on Handle and ServeHTTP (#446)
|
||||
- List available representations in 406 body (#437)
|
||||
- Convert to string using rune() (#443)
|
||||
|
||||
## [v2.13.0] - 2020-06-21
|
||||
## v2.13.0 - 2020-06-21
|
||||
|
||||
- 405 Method Not Allowed must have Allow header (#436)
|
||||
- add field allowedMethodsWithoutContentType (#424)
|
||||
|
||||
5
vendor/github.com/emicklei/go-restful/Makefile
generated
vendored
5
vendor/github.com/emicklei/go-restful/Makefile
generated
vendored
@@ -2,7 +2,4 @@ all: test
|
||||
|
||||
test:
|
||||
go vet .
|
||||
go test -cover -v .
|
||||
|
||||
ex:
|
||||
cd examples && ls *.go | xargs go build -o /tmp/ignore
|
||||
go test -cover -v .
|
||||
28
vendor/github.com/emicklei/go-restful/README.md
generated
vendored
28
vendor/github.com/emicklei/go-restful/README.md
generated
vendored
@@ -7,7 +7,7 @@ package for building REST-style Web Services using Google Go
|
||||
[](https://pkg.go.dev/github.com/emicklei/go-restful)
|
||||
[](https://codecov.io/gh/emicklei/go-restful)
|
||||
|
||||
- [Code examples](https://github.com/emicklei/go-restful/tree/master/examples)
|
||||
- [Code examples using v3](https://github.com/emicklei/go-restful/tree/master/examples)
|
||||
|
||||
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:
|
||||
|
||||
@@ -21,16 +21,6 @@ REST asks developers to use HTTP methods explicitly and in a way that's consiste
|
||||
|
||||
### 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.
|
||||
@@ -41,6 +31,16 @@ import (
|
||||
)
|
||||
```
|
||||
|
||||
#### Without Go Modules
|
||||
|
||||
All versions up to `v2.*.*` (on the master) are not supporting Go modules.
|
||||
|
||||
```
|
||||
import (
|
||||
restful "github.com/emicklei/go-restful"
|
||||
)
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```Go
|
||||
@@ -61,9 +61,9 @@ func (u UserResource) findUser(request *restful.Request, response *restful.Respo
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
[Full API of a UserResource](https://github.com/emicklei/go-restful/tree/master/examples/restful-user-resource.go)
|
||||
|
||||
|
||||
[Full API of a UserResource](https://github.com/emicklei/go-restful/tree/master/examples/user-resource/restful-user-resource.go)
|
||||
|
||||
### Features
|
||||
|
||||
- Routes for request → function mapping with path parameter (e.g. {id} but also prefix_{var} and {var}_suffix) support
|
||||
|
||||
67
vendor/github.com/emicklei/go-restful/cors_filter.go
generated
vendored
67
vendor/github.com/emicklei/go-restful/cors_filter.go
generated
vendored
@@ -18,9 +18,22 @@ import (
|
||||
// http://enable-cors.org/server.html
|
||||
// http://www.html5rocks.com/en/tutorials/cors/#toc-handling-a-not-so-simple-request
|
||||
type CrossOriginResourceSharing struct {
|
||||
ExposeHeaders []string // list of Header names
|
||||
AllowedHeaders []string // list of Header names
|
||||
AllowedDomains []string // list of allowed values for Http Origin. An allowed value can be a regular expression to support subdomain matching. If empty all are allowed.
|
||||
ExposeHeaders []string // list of Header names
|
||||
|
||||
// AllowedHeaders is alist of Header names. Checking is case-insensitive.
|
||||
// The list may contain the special wildcard string ".*" ; all is allowed
|
||||
AllowedHeaders []string
|
||||
|
||||
// AllowedDomains is a list of allowed values for Http Origin.
|
||||
// The list may contain the special wildcard string ".*" ; all is allowed
|
||||
// If empty all are allowed.
|
||||
AllowedDomains []string
|
||||
|
||||
// AllowedDomainFunc is optional and is a function that will do the check
|
||||
// when the origin is not part of the AllowedDomains and it does not contain the wildcard ".*".
|
||||
AllowedDomainFunc func(origin string) bool
|
||||
|
||||
// AllowedMethods is either empty or has a list of http methods names. Checking is case-insensitive.
|
||||
AllowedMethods []string
|
||||
MaxAge int // number of seconds before requiring new Options request
|
||||
CookiesAllowed bool
|
||||
@@ -119,36 +132,24 @@ func (c CrossOriginResourceSharing) isOriginAllowed(origin string) bool {
|
||||
if len(origin) == 0 {
|
||||
return false
|
||||
}
|
||||
lowerOrigin := strings.ToLower(origin)
|
||||
if len(c.AllowedDomains) == 0 {
|
||||
if c.AllowedDomainFunc != nil {
|
||||
return c.AllowedDomainFunc(lowerOrigin)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
allowed := false
|
||||
// exact match on each allowed domain
|
||||
for _, domain := range c.AllowedDomains {
|
||||
if domain == origin {
|
||||
allowed = true
|
||||
break
|
||||
if domain == ".*" || strings.ToLower(domain) == lowerOrigin {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
if !allowed {
|
||||
if len(c.allowedOriginPatterns) == 0 {
|
||||
// compile allowed domains to allowed origin patterns
|
||||
allowedOriginRegexps, err := compileRegexps(c.AllowedDomains)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
c.allowedOriginPatterns = allowedOriginRegexps
|
||||
}
|
||||
|
||||
for _, pattern := range c.allowedOriginPatterns {
|
||||
if allowed = pattern.MatchString(origin); allowed {
|
||||
break
|
||||
}
|
||||
}
|
||||
if c.AllowedDomainFunc != nil {
|
||||
return c.AllowedDomainFunc(origin)
|
||||
}
|
||||
|
||||
return allowed
|
||||
return false
|
||||
}
|
||||
|
||||
func (c CrossOriginResourceSharing) setAllowOriginHeader(req *Request, resp *Response) {
|
||||
@@ -184,19 +185,9 @@ func (c CrossOriginResourceSharing) isValidAccessControlRequestHeader(header str
|
||||
if strings.ToLower(each) == strings.ToLower(header) {
|
||||
return true
|
||||
}
|
||||
if each == "*" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Take a list of strings and compile them into a list of regular expressions.
|
||||
func compileRegexps(regexpStrings []string) ([]*regexp.Regexp, error) {
|
||||
regexps := []*regexp.Regexp{}
|
||||
for _, regexpStr := range regexpStrings {
|
||||
r, err := regexp.Compile(regexpStr)
|
||||
if err != nil {
|
||||
return regexps, err
|
||||
}
|
||||
regexps = append(regexps, r)
|
||||
}
|
||||
return regexps, nil
|
||||
}
|
||||
|
||||
8
vendor/github.com/emicklei/go-restful/parameter.go
generated
vendored
8
vendor/github.com/emicklei/go-restful/parameter.go
generated
vendored
@@ -20,6 +20,9 @@ const (
|
||||
// FormParameterKind = indicator of Request parameter type "form"
|
||||
FormParameterKind
|
||||
|
||||
// MultiPartFormParameterKind = indicator of Request parameter type "multipart/form-data"
|
||||
MultiPartFormParameterKind
|
||||
|
||||
// CollectionFormatCSV comma separated values `foo,bar`
|
||||
CollectionFormatCSV = CollectionFormat("csv")
|
||||
|
||||
@@ -94,6 +97,11 @@ func (p *Parameter) beForm() *Parameter {
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *Parameter) beMultiPartForm() *Parameter {
|
||||
p.data.Kind = MultiPartFormParameterKind
|
||||
return p
|
||||
}
|
||||
|
||||
// Required sets the required field and returns the receiver
|
||||
func (p *Parameter) Required(required bool) *Parameter {
|
||||
p.data.Required = required
|
||||
|
||||
8
vendor/github.com/emicklei/go-restful/request.go
generated
vendored
8
vendor/github.com/emicklei/go-restful/request.go
generated
vendored
@@ -17,6 +17,7 @@ type Request struct {
|
||||
pathParameters map[string]string
|
||||
attributes map[string]interface{} // for storing request-scoped values
|
||||
selectedRoutePath string // root path + route path that matched the request, e.g. /meetings/{id}/attendees
|
||||
selectedRoute *Route
|
||||
}
|
||||
|
||||
func NewRequest(httpRequest *http.Request) *Request {
|
||||
@@ -114,5 +115,10 @@ func (r Request) Attribute(name string) interface{} {
|
||||
|
||||
// SelectedRoutePath root path + route path that matched the request, e.g. /meetings/{id}/attendees
|
||||
func (r Request) SelectedRoutePath() string {
|
||||
return r.selectedRoutePath
|
||||
return r.selectedRoute.Path
|
||||
}
|
||||
|
||||
// SelectedRoute return the Route that selected by the container
|
||||
func (r Request) SelectedRoute() RouteReader {
|
||||
return routeAccessor{route: r.selectedRoute}
|
||||
}
|
||||
|
||||
2
vendor/github.com/emicklei/go-restful/response.go
generated
vendored
2
vendor/github.com/emicklei/go-restful/response.go
generated
vendored
@@ -175,7 +175,7 @@ func (r *Response) WriteHeaderAndJson(status int, value interface{}, contentType
|
||||
}
|
||||
|
||||
// WriteError writes the http status and the error string on the response. err can be nil.
|
||||
// Return an error if writing was not succesful.
|
||||
// Return an error if writing was not successful.
|
||||
func (r *Response) WriteError(httpStatus int, err error) (writeErr error) {
|
||||
r.err = err
|
||||
if err == nil {
|
||||
|
||||
2
vendor/github.com/emicklei/go-restful/route.go
generated
vendored
2
vendor/github.com/emicklei/go-restful/route.go
generated
vendored
@@ -69,7 +69,7 @@ func (r *Route) postBuild() {
|
||||
func (r *Route) wrapRequestResponse(httpWriter http.ResponseWriter, httpRequest *http.Request, pathParams map[string]string) (*Request, *Response) {
|
||||
wrappedRequest := NewRequest(httpRequest)
|
||||
wrappedRequest.pathParameters = pathParams
|
||||
wrappedRequest.selectedRoutePath = r.Path
|
||||
wrappedRequest.selectedRoute = r
|
||||
wrappedResponse := NewResponse(httpWriter)
|
||||
wrappedResponse.requestAccept = httpRequest.Header.Get(HEADER_Accept)
|
||||
wrappedResponse.routeProduces = r.Produces
|
||||
|
||||
66
vendor/github.com/emicklei/go-restful/route_reader.go
generated
vendored
Normal file
66
vendor/github.com/emicklei/go-restful/route_reader.go
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
package restful
|
||||
|
||||
// Copyright 2021 Ernest Micklei. All rights reserved.
|
||||
// Use of this source code is governed by a license
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
type RouteReader interface {
|
||||
Method() string
|
||||
Consumes() []string
|
||||
Path() string
|
||||
Doc() string
|
||||
Notes() string
|
||||
Operation() string
|
||||
ParameterDocs() []*Parameter
|
||||
// Returns a copy
|
||||
Metadata() map[string]interface{}
|
||||
Deprecated() bool
|
||||
}
|
||||
|
||||
type routeAccessor struct {
|
||||
route *Route
|
||||
}
|
||||
|
||||
func (r routeAccessor) Method() string {
|
||||
return r.route.Method
|
||||
}
|
||||
func (r routeAccessor) Consumes() []string {
|
||||
return r.route.Consumes[:]
|
||||
}
|
||||
func (r routeAccessor) Path() string {
|
||||
return r.route.Path
|
||||
}
|
||||
func (r routeAccessor) Doc() string {
|
||||
return r.route.Doc
|
||||
}
|
||||
func (r routeAccessor) Notes() string {
|
||||
return r.route.Notes
|
||||
}
|
||||
func (r routeAccessor) Operation() string {
|
||||
return r.route.Operation
|
||||
}
|
||||
func (r routeAccessor) ParameterDocs() []*Parameter {
|
||||
return r.route.ParameterDocs[:]
|
||||
}
|
||||
|
||||
// Returns a copy
|
||||
func (r routeAccessor) Metadata() map[string]interface{} {
|
||||
return copyMap(r.route.Metadata)
|
||||
}
|
||||
func (r routeAccessor) Deprecated() bool {
|
||||
return r.route.Deprecated
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/23057785/how-to-copy-a-map
|
||||
func copyMap(m map[string]interface{}) map[string]interface{} {
|
||||
cp := make(map[string]interface{})
|
||||
for k, v := range m {
|
||||
vm, ok := v.(map[string]interface{})
|
||||
if ok {
|
||||
cp[k] = copyMap(vm)
|
||||
} else {
|
||||
cp[k] = v
|
||||
}
|
||||
}
|
||||
return cp
|
||||
}
|
||||
17
vendor/github.com/emicklei/go-restful/web_service.go
generated
vendored
17
vendor/github.com/emicklei/go-restful/web_service.go
generated
vendored
@@ -165,6 +165,18 @@ func FormParameter(name, description string) *Parameter {
|
||||
return p
|
||||
}
|
||||
|
||||
// MultiPartFormParameter creates a new Parameter of kind Form (using multipart/form-data) for documentation purposes.
|
||||
// It is initialized as required with string as its DataType.
|
||||
func (w *WebService) MultiPartFormParameter(name, description string) *Parameter {
|
||||
return MultiPartFormParameter(name, description)
|
||||
}
|
||||
|
||||
func MultiPartFormParameter(name, description string) *Parameter {
|
||||
p := &Parameter{&ParameterData{Name: name, Description: description, Required: false, DataType: "string"}}
|
||||
p.beMultiPartForm()
|
||||
return p
|
||||
}
|
||||
|
||||
// Route creates a new Route using the RouteBuilder and add to the ordered list of Routes.
|
||||
func (w *WebService) Route(builder *RouteBuilder) *WebService {
|
||||
w.routesLock.Lock()
|
||||
@@ -288,3 +300,8 @@ func (w *WebService) PATCH(subPath string) *RouteBuilder {
|
||||
func (w *WebService) DELETE(subPath string) *RouteBuilder {
|
||||
return new(RouteBuilder).typeNameHandler(w.typeNameHandleFunc).servicePath(w.rootPath).Method("DELETE").Path(subPath)
|
||||
}
|
||||
|
||||
// OPTIONS is a shortcut for .Method("OPTIONS").Path(subPath)
|
||||
func (w *WebService) OPTIONS(subPath string) *RouteBuilder {
|
||||
return new(RouteBuilder).typeNameHandler(w.typeNameHandleFunc).servicePath(w.rootPath).Method("OPTIONS").Path(subPath)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user