From 673fdde52ce5f9ea1385c994153590f9d909ed4c Mon Sep 17 00:00:00 2001 From: hongming Date: Tue, 9 May 2023 10:13:45 +0800 Subject: [PATCH] Bump github.com/emicklei/go-restful-openapi to v2.9.2-0.20230507070325-d6acc08e570c (#5669) --- .../go-restful-openapi/{ => v2}/LICENSE | 4 +- .../github.com/emicklei/go-restful/LICENSE | 25 - .../github.com/emicklei/go-restful/v3/LICENSE | 2 +- go.mod | 10 +- go.sum | 13 +- pkg/api/alerting/v2alpha1/types.go | 2 +- pkg/api/alerting/v2alpha1/types_test.go | 2 +- pkg/api/auditing/v1alpha1/types.go | 2 +- pkg/api/auditing/v1alpha1/types_test.go | 2 +- pkg/api/events/v1alpha1/types.go | 2 +- pkg/api/events/v1alpha1/types_test.go | 2 +- pkg/api/logging/v1alpha2/types.go | 2 +- pkg/api/logging/v1alpha2/types_test.go | 2 +- pkg/api/metering/v1alpha1/types.go | 2 +- pkg/api/metering/v1alpha1/types_test.go | 2 +- pkg/api/utils.go | 2 +- pkg/apiserver/apiserver.go | 2 +- pkg/apiserver/filters/dynamicresource.go | 2 +- pkg/apiserver/query/types.go | 2 +- pkg/apiserver/query/types_test.go | 2 +- pkg/apiserver/runtime/runtime.go | 2 +- pkg/kapis/alerting/v1/register.go | 2 +- pkg/kapis/alerting/v2alpha1/handler.go | 2 +- pkg/kapis/alerting/v2alpha1/register.go | 4 +- pkg/kapis/alerting/v2beta1/handler.go | 2 +- pkg/kapis/alerting/v2beta1/register.go | 4 +- pkg/kapis/cluster/v1alpha1/handler.go | 2 +- pkg/kapis/cluster/v1alpha1/register.go | 4 +- pkg/kapis/config/v1alpha2/register.go | 2 +- pkg/kapis/devops/register.go | 2 +- pkg/kapis/devops/register_test.go | 2 +- pkg/kapis/edgeruntime/v1alpha1/register.go | 2 +- pkg/kapis/gateway/v1alpha1/handler.go | 2 +- pkg/kapis/gateway/v1alpha1/register.go | 4 +- pkg/kapis/generic/generic.go | 2 +- pkg/kapis/generic/generic_test.go | 2 +- pkg/kapis/iam/v1alpha2/handler.go | 2 +- pkg/kapis/iam/v1alpha2/register.go | 4 +- pkg/kapis/kubeedge/v1alpha1/register.go | 2 +- pkg/kapis/metering/v1alpha1/handler.go | 2 +- pkg/kapis/metering/v1alpha1/register.go | 4 +- pkg/kapis/monitoring/v1alpha3/handler.go | 2 +- pkg/kapis/monitoring/v1alpha3/helper.go | 2 +- pkg/kapis/monitoring/v1alpha3/meter.go | 2 +- pkg/kapis/monitoring/v1alpha3/register.go | 4 +- pkg/kapis/network/v1alpha2/handler.go | 2 +- pkg/kapis/network/v1alpha2/register.go | 4 +- pkg/kapis/notification/v1/register.go | 2 +- pkg/kapis/notification/v2beta1/handler.go | 2 +- pkg/kapis/notification/v2beta1/register.go | 6 +- pkg/kapis/notification/v2beta2/handler.go | 2 +- pkg/kapis/notification/v2beta2/register.go | 6 +- pkg/kapis/oauth/handler.go | 2 +- pkg/kapis/oauth/register.go | 4 +- pkg/kapis/openpitrix/v1/handler.go | 5 +- pkg/kapis/openpitrix/v1/register.go | 4 +- pkg/kapis/openpitrix/v2alpha1/handler.go | 2 +- pkg/kapis/openpitrix/v2alpha1/register.go | 4 +- pkg/kapis/operations/v1alpha2/handler.go | 2 +- pkg/kapis/operations/v1alpha2/register.go | 2 +- pkg/kapis/resources/v1alpha2/handler.go | 2 +- pkg/kapis/resources/v1alpha2/register.go | 4 +- pkg/kapis/resources/v1alpha3/handler.go | 2 +- pkg/kapis/resources/v1alpha3/handler_test.go | 2 +- pkg/kapis/resources/v1alpha3/register.go | 4 +- .../servicemesh/metrics/install/install.go | 2 +- .../servicemesh/metrics/v1alpha2/handler.go | 2 +- .../metrics/v1alpha2/handler_test.go | 2 +- .../servicemesh/metrics/v1alpha2/register.go | 4 +- pkg/kapis/tenant/v1alpha2/handler.go | 2 +- pkg/kapis/tenant/v1alpha2/metering.go | 2 +- pkg/kapis/tenant/v1alpha2/register.go | 4 +- pkg/kapis/tenant/v1alpha3/handler.go | 2 +- pkg/kapis/tenant/v1alpha3/register.go | 4 +- pkg/kapis/terminal/v1alpha2/handler.go | 2 +- pkg/kapis/terminal/v1alpha2/register.go | 4 +- pkg/kapis/version/register.go | 2 +- .../devops/project_pipeline_sonar_handler.go | 2 +- pkg/models/devops/s2ibinary_handler.go | 2 +- pkg/models/notification/notification.go | 2 +- pkg/models/registries/manifest.go | 2 +- pkg/models/registries/registries.go | 2 +- pkg/server/errors/errors.go | 2 +- pkg/server/healthz/healthz.go | 2 +- pkg/server/params/params.go | 2 +- pkg/server/params/params_test.go | 2 +- pkg/simple/client/devops/fake/fakedevops.go | 2 +- pkg/simple/client/devops/jenkins/build.go | 2 +- .../client/devops/jenkins/credential.go | 2 +- pkg/simple/client/devops/jenkins/project.go | 2 +- .../client/devops/jenkins/project_pipeline.go | 2 +- pkg/utils/metrics/metrics.go | 2 +- staging/src/kubesphere.io/api/go.mod | 2 +- staging/src/kubesphere.io/api/go.sum | 4 +- staging/src/kubesphere.io/client-go/go.mod | 2 +- staging/src/kubesphere.io/client-go/go.sum | 4 +- staging/src/kubesphere.io/utils/go.mod | 2 +- staging/src/kubesphere.io/utils/go.sum | 4 +- tools/cmd/doc-gen/main.go | 2 +- .../emicklei/go-restful-openapi/.travis.yml | 4 - .../go-restful-openapi/{ => v2}/.gitignore | 1 + .../go-restful-openapi/v2/.golangci.yml | 103 ++++ .../go-restful-openapi/v2/.travis.yml | 13 + .../go-restful-openapi/{ => v2}/CHANGES.md | 46 ++ .../go-restful-openapi/{ => v2}/LICENSE | 0 .../emicklei/go-restful-openapi/v2/Makefile | 20 + .../go-restful-openapi/{ => v2}/README.md | 2 +- .../{ => v2}/build_definitions.go | 2 +- .../go-restful-openapi/{ => v2}/build_path.go | 199 ++++++-- .../go-restful-openapi/{ => v2}/config.go | 23 +- .../{ => v2}/definition_builder.go | 39 +- .../go-restful-openapi/v2/definition_name.go | 105 +++++ .../go-restful-openapi/{ => v2}/lookup.go | 2 +- .../{ => v2}/property_ext.go | 38 +- .../{ => v2}/spec_resource.go | 3 +- .../github.com/emicklei/go-restful/.gitignore | 71 --- .../emicklei/go-restful/.travis.yml | 13 - .../github.com/emicklei/go-restful/CHANGES.md | 318 ------------- vendor/github.com/emicklei/go-restful/LICENSE | 22 - .../github.com/emicklei/go-restful/Makefile | 5 - .../github.com/emicklei/go-restful/README.md | 111 ----- vendor/github.com/emicklei/go-restful/Srcfile | 1 - .../emicklei/go-restful/bench_test.sh | 10 - .../emicklei/go-restful/compress.go | 123 ----- .../emicklei/go-restful/compressor_cache.go | 103 ---- .../emicklei/go-restful/compressor_pools.go | 91 ---- .../emicklei/go-restful/compressors.go | 54 --- .../emicklei/go-restful/constants.go | 30 -- .../emicklei/go-restful/container.go | 445 ------------------ .../emicklei/go-restful/cors_filter.go | 193 -------- .../emicklei/go-restful/coverage.sh | 2 - .../github.com/emicklei/go-restful/curly.go | 173 ------- .../emicklei/go-restful/curly_route.go | 54 --- .../emicklei/go-restful/custom_verb.go | 29 -- vendor/github.com/emicklei/go-restful/doc.go | 185 -------- .../emicklei/go-restful/entity_accessors.go | 162 ------- .../github.com/emicklei/go-restful/filter.go | 35 -- vendor/github.com/emicklei/go-restful/json.go | 11 - .../emicklei/go-restful/jsoniter.go | 12 - .../github.com/emicklei/go-restful/jsr311.go | 316 ------------- .../github.com/emicklei/go-restful/log/log.go | 34 -- .../github.com/emicklei/go-restful/logger.go | 32 -- vendor/github.com/emicklei/go-restful/mime.go | 50 -- .../emicklei/go-restful/options_filter.go | 34 -- .../emicklei/go-restful/parameter.go | 151 ------ .../emicklei/go-restful/path_expression.go | 74 --- .../emicklei/go-restful/path_processor.go | 74 --- .../github.com/emicklei/go-restful/request.go | 124 ----- .../emicklei/go-restful/response.go | 256 ---------- .../github.com/emicklei/go-restful/route.go | 177 ------- .../emicklei/go-restful/route_builder.go | 364 -------------- .../emicklei/go-restful/route_reader.go | 66 --- .../github.com/emicklei/go-restful/router.go | 20 - .../emicklei/go-restful/service_error.go | 32 -- .../emicklei/go-restful/v3/CHANGES.md | 5 + .../emicklei/go-restful/v3/README.md | 4 + .../emicklei/go-restful/v3/route_builder.go | 24 +- .../emicklei/go-restful/web_service.go | 307 ------------ .../go-restful/web_service_container.go | 39 -- vendor/modules.txt | 15 +- 160 files changed, 709 insertions(+), 4635 deletions(-) rename LICENSES/vendor/github.com/emicklei/go-restful-openapi/{ => v2}/LICENSE (86%) delete mode 100644 LICENSES/vendor/github.com/emicklei/go-restful/LICENSE delete mode 100644 vendor/github.com/emicklei/go-restful-openapi/.travis.yml rename vendor/github.com/emicklei/go-restful-openapi/{ => v2}/.gitignore (72%) create mode 100644 vendor/github.com/emicklei/go-restful-openapi/v2/.golangci.yml create mode 100644 vendor/github.com/emicklei/go-restful-openapi/v2/.travis.yml rename vendor/github.com/emicklei/go-restful-openapi/{ => v2}/CHANGES.md (57%) rename vendor/github.com/emicklei/go-restful-openapi/{ => v2}/LICENSE (100%) create mode 100644 vendor/github.com/emicklei/go-restful-openapi/v2/Makefile rename vendor/github.com/emicklei/go-restful-openapi/{ => v2}/README.md (97%) rename vendor/github.com/emicklei/go-restful-openapi/{ => v2}/build_definitions.go (94%) rename vendor/github.com/emicklei/go-restful-openapi/{ => v2}/build_path.go (54%) rename vendor/github.com/emicklei/go-restful-openapi/{ => v2}/config.go (60%) rename vendor/github.com/emicklei/go-restful-openapi/{ => v2}/definition_builder.go (94%) create mode 100644 vendor/github.com/emicklei/go-restful-openapi/v2/definition_name.go rename vendor/github.com/emicklei/go-restful-openapi/{ => v2}/lookup.go (88%) rename vendor/github.com/emicklei/go-restful-openapi/{ => v2}/property_ext.go (71%) rename vendor/github.com/emicklei/go-restful-openapi/{ => v2}/spec_resource.go (96%) delete mode 100644 vendor/github.com/emicklei/go-restful/.gitignore delete mode 100644 vendor/github.com/emicklei/go-restful/.travis.yml delete mode 100644 vendor/github.com/emicklei/go-restful/CHANGES.md delete mode 100644 vendor/github.com/emicklei/go-restful/LICENSE delete mode 100644 vendor/github.com/emicklei/go-restful/Makefile delete mode 100644 vendor/github.com/emicklei/go-restful/README.md delete mode 100644 vendor/github.com/emicklei/go-restful/Srcfile delete mode 100644 vendor/github.com/emicklei/go-restful/bench_test.sh delete mode 100644 vendor/github.com/emicklei/go-restful/compress.go delete mode 100644 vendor/github.com/emicklei/go-restful/compressor_cache.go delete mode 100644 vendor/github.com/emicklei/go-restful/compressor_pools.go delete mode 100644 vendor/github.com/emicklei/go-restful/compressors.go delete mode 100644 vendor/github.com/emicklei/go-restful/constants.go delete mode 100644 vendor/github.com/emicklei/go-restful/container.go delete mode 100644 vendor/github.com/emicklei/go-restful/cors_filter.go delete mode 100644 vendor/github.com/emicklei/go-restful/coverage.sh delete mode 100644 vendor/github.com/emicklei/go-restful/curly.go delete mode 100644 vendor/github.com/emicklei/go-restful/curly_route.go delete mode 100644 vendor/github.com/emicklei/go-restful/custom_verb.go delete mode 100644 vendor/github.com/emicklei/go-restful/doc.go delete mode 100644 vendor/github.com/emicklei/go-restful/entity_accessors.go delete mode 100644 vendor/github.com/emicklei/go-restful/filter.go delete mode 100644 vendor/github.com/emicklei/go-restful/json.go delete mode 100644 vendor/github.com/emicklei/go-restful/jsoniter.go delete mode 100644 vendor/github.com/emicklei/go-restful/jsr311.go delete mode 100644 vendor/github.com/emicklei/go-restful/log/log.go delete mode 100644 vendor/github.com/emicklei/go-restful/logger.go delete mode 100644 vendor/github.com/emicklei/go-restful/mime.go delete mode 100644 vendor/github.com/emicklei/go-restful/options_filter.go delete mode 100644 vendor/github.com/emicklei/go-restful/parameter.go delete mode 100644 vendor/github.com/emicklei/go-restful/path_expression.go delete mode 100644 vendor/github.com/emicklei/go-restful/path_processor.go delete mode 100644 vendor/github.com/emicklei/go-restful/request.go delete mode 100644 vendor/github.com/emicklei/go-restful/response.go delete mode 100644 vendor/github.com/emicklei/go-restful/route.go delete mode 100644 vendor/github.com/emicklei/go-restful/route_builder.go delete mode 100644 vendor/github.com/emicklei/go-restful/route_reader.go delete mode 100644 vendor/github.com/emicklei/go-restful/router.go delete mode 100644 vendor/github.com/emicklei/go-restful/service_error.go delete mode 100644 vendor/github.com/emicklei/go-restful/web_service.go delete mode 100644 vendor/github.com/emicklei/go-restful/web_service_container.go diff --git a/LICENSES/vendor/github.com/emicklei/go-restful-openapi/LICENSE b/LICENSES/vendor/github.com/emicklei/go-restful-openapi/v2/LICENSE similarity index 86% rename from LICENSES/vendor/github.com/emicklei/go-restful-openapi/LICENSE rename to LICENSES/vendor/github.com/emicklei/go-restful-openapi/v2/LICENSE index ee39b1c3d..acdb99d5a 100644 --- a/LICENSES/vendor/github.com/emicklei/go-restful-openapi/LICENSE +++ b/LICENSES/vendor/github.com/emicklei/go-restful-openapi/v2/LICENSE @@ -1,4 +1,4 @@ -= vendor/github.com/emicklei/go-restful-openapi licensed under: = += vendor/github.com/emicklei/go-restful-openapi/v2 licensed under: = Copyright (c) 2017 Ernest Micklei @@ -22,4 +22,4 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -= vendor/github.com/emicklei/go-restful-openapi/LICENSE b1ce415d97e837c8677d332b274d4f0b += vendor/github.com/emicklei/go-restful-openapi/v2/LICENSE b1ce415d97e837c8677d332b274d4f0b diff --git a/LICENSES/vendor/github.com/emicklei/go-restful/LICENSE b/LICENSES/vendor/github.com/emicklei/go-restful/LICENSE deleted file mode 100644 index 9a6a3a0a7..000000000 --- a/LICENSES/vendor/github.com/emicklei/go-restful/LICENSE +++ /dev/null @@ -1,25 +0,0 @@ -= vendor/github.com/emicklei/go-restful licensed under: = - -Copyright (c) 2012,2013 Ernest Micklei - -MIT License - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -= vendor/github.com/emicklei/go-restful/LICENSE 2ebc1c12a0f4eae5394522e31961e1de diff --git a/LICENSES/vendor/github.com/emicklei/go-restful/v3/LICENSE b/LICENSES/vendor/github.com/emicklei/go-restful/v3/LICENSE index 2fc1ba12f..fbb67f381 100644 --- a/LICENSES/vendor/github.com/emicklei/go-restful/v3/LICENSE +++ b/LICENSES/vendor/github.com/emicklei/go-restful/v3/LICENSE @@ -22,4 +22,4 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -= vendor/github.com/emicklei/go-restful/LICENSE 2ebc1c12a0f4eae5394522e31961e1de += vendor/github.com/emicklei/go-restful/v3/LICENSE 2ebc1c12a0f4eae5394522e31961e1de diff --git a/go.mod b/go.mod index 92da48cb1..ca2c22105 100644 --- a/go.mod +++ b/go.mod @@ -23,8 +23,8 @@ require ( github.com/elastic/go-elasticsearch/v5 v5.6.1 github.com/elastic/go-elasticsearch/v6 v6.8.2 github.com/elastic/go-elasticsearch/v7 v7.3.0 - github.com/emicklei/go-restful v2.16.0+incompatible - github.com/emicklei/go-restful-openapi v1.4.1 + github.com/emicklei/go-restful-openapi/v2 v2.9.1 + github.com/emicklei/go-restful/v3 v3.10.2 github.com/evanphx/json-patch v5.6.0+incompatible github.com/fatih/structs v1.1.0 github.com/fsnotify/fsnotify v1.6.0 @@ -143,7 +143,6 @@ require ( github.com/docker/go-units v0.5.0 // indirect github.com/edsrzf/mmap-go v1.1.0 // indirect github.com/efficientgo/tools/core v0.0.0-20220225185207-fe763185946b // indirect - github.com/emicklei/go-restful/v3 v3.10.1 // indirect github.com/emirpasic/gods v1.12.0 // indirect github.com/evanphx/json-patch/v5 v5.6.0 // indirect github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect @@ -338,9 +337,8 @@ replace ( github.com/elastic/go-elasticsearch/v5 => github.com/elastic/go-elasticsearch/v5 v5.6.1 github.com/elastic/go-elasticsearch/v6 => github.com/elastic/go-elasticsearch/v6 v6.8.2 github.com/elastic/go-elasticsearch/v7 => github.com/elastic/go-elasticsearch/v7 v7.3.0 - github.com/emicklei/go-restful => github.com/emicklei/go-restful v2.16.0+incompatible - github.com/emicklei/go-restful-openapi => github.com/emicklei/go-restful-openapi v1.4.1 - github.com/emicklei/go-restful/v3 => github.com/emicklei/go-restful/v3 v3.10.1 + github.com/emicklei/go-restful-openapi/v2 => github.com/emicklei/go-restful-openapi/v2 v2.9.2-0.20230507070325-d6acc08e570c + github.com/emicklei/go-restful/v3 => github.com/emicklei/go-restful/v3 v3.10.2 github.com/emirpasic/gods => github.com/emirpasic/gods v1.12.0 github.com/evanphx/json-patch => github.com/evanphx/json-patch v5.6.0+incompatible github.com/evanphx/json-patch/v5 => github.com/evanphx/json-patch/v5 v5.6.0 diff --git a/go.sum b/go.sum index b1c1c22e9..8a639ba1b 100644 --- a/go.sum +++ b/go.sum @@ -264,7 +264,6 @@ github.com/OneOfOne/xxhash v1.2.8 h1:31czK/TI9sNkxIKfaUfGlU47BAxQ0ztGgd9vPyqimf8 github.com/OneOfOne/xxhash v1.2.8/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q= github.com/PuerkitoBio/goquery v1.5.0 h1:uGvmFXOA73IKluu/F84Xd1tt/z07GYm8X49XKHP7EJk= github.com/PuerkitoBio/goquery v1.5.0/go.mod h1:qD2PgZ9lccMbQlc7eEOjaeRlFQON7xY8kdmcsrnKqMg= -github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d h1:UrqY+r/OJnIp5u0s1SbQ8dVfLCZJsnvazdBP5hS4iRs= @@ -496,12 +495,12 @@ github.com/elastic/go-elasticsearch/v7 v7.3.0 h1:H29Nqf9cB9dVxX6LwS+zTDC2D4t9s+8 github.com/elastic/go-elasticsearch/v7 v7.3.0/go.mod h1:OJ4wdbtDNk5g503kvlHLyErCgQwwzmDtaFC4XyOxXA4= github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153 h1:yUdfgN0XgIJw7foRItutHYUIhlcKzcSf5vDpdhQAKTc= github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= -github.com/emicklei/go-restful v2.16.0+incompatible h1:rgqiKNjTnFQA6kkhFe16D8epTksy9HQ1MyrbDXSdYhM= -github.com/emicklei/go-restful v2.16.0+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= -github.com/emicklei/go-restful-openapi v1.4.1 h1:SocVTIQWnXyit4dotTrwmncBAjtRaBmfcHjo3XGcCm4= -github.com/emicklei/go-restful-openapi v1.4.1/go.mod h1:kWQ8rQMVQ6G6lePwjDveJ00KjAUr/jq6z1X8DrDP3Gc= -github.com/emicklei/go-restful/v3 v3.10.1 h1:rc42Y5YTp7Am7CS630D7JmhRjq4UlEUuEKfrDac4bSQ= -github.com/emicklei/go-restful/v3 v3.10.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= +github.com/emicklei/go-restful v2.11.2-0.20200112161605-a7c079c43d51+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= +github.com/emicklei/go-restful-openapi/v2 v2.9.2-0.20230507070325-d6acc08e570c h1:Fr2oTQtTLMbCXMdhUnnsrDVRTPauJLFYHtNtcc/RSL0= +github.com/emicklei/go-restful-openapi/v2 v2.9.2-0.20230507070325-d6acc08e570c/go.mod h1:I//7paNAkpeGWmBYZ2JLq/timz5YWI/bcUeBMstEfKo= +github.com/emicklei/go-restful/v3 v3.10.2 h1:hIovbnmBTLjHXkqEBUz3HGpXZdM7ZrE9fJIZIqlJLqE= +github.com/emicklei/go-restful/v3 v3.10.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= diff --git a/pkg/api/alerting/v2alpha1/types.go b/pkg/api/alerting/v2alpha1/types.go index b9cf49dca..c78cc1913 100644 --- a/pkg/api/alerting/v2alpha1/types.go +++ b/pkg/api/alerting/v2alpha1/types.go @@ -24,7 +24,7 @@ import ( "strings" "time" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "github.com/pkg/errors" prommodel "github.com/prometheus/common/model" "github.com/prometheus/prometheus/model/timestamp" diff --git a/pkg/api/alerting/v2alpha1/types_test.go b/pkg/api/alerting/v2alpha1/types_test.go index fa441f586..86263446f 100644 --- a/pkg/api/alerting/v2alpha1/types_test.go +++ b/pkg/api/alerting/v2alpha1/types_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "github.com/prometheus/prometheus/rules" "github.com/stretchr/testify/assert" ) diff --git a/pkg/api/auditing/v1alpha1/types.go b/pkg/api/auditing/v1alpha1/types.go index 2629cd9a9..b6276893a 100644 --- a/pkg/api/auditing/v1alpha1/types.go +++ b/pkg/api/auditing/v1alpha1/types.go @@ -20,7 +20,7 @@ import ( "strconv" "time" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "kubesphere.io/kubesphere/pkg/simple/client/auditing" ) diff --git a/pkg/api/auditing/v1alpha1/types_test.go b/pkg/api/auditing/v1alpha1/types_test.go index 5c47a196f..5293c5859 100644 --- a/pkg/api/auditing/v1alpha1/types_test.go +++ b/pkg/api/auditing/v1alpha1/types_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "github.com/stretchr/testify/assert" ) diff --git a/pkg/api/events/v1alpha1/types.go b/pkg/api/events/v1alpha1/types.go index 02effcc5f..285c83061 100644 --- a/pkg/api/events/v1alpha1/types.go +++ b/pkg/api/events/v1alpha1/types.go @@ -20,7 +20,7 @@ import ( "strconv" "time" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "kubesphere.io/kubesphere/pkg/simple/client/events" ) diff --git a/pkg/api/events/v1alpha1/types_test.go b/pkg/api/events/v1alpha1/types_test.go index 571c5ebf8..b7ae7e988 100644 --- a/pkg/api/events/v1alpha1/types_test.go +++ b/pkg/api/events/v1alpha1/types_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "github.com/stretchr/testify/assert" ) diff --git a/pkg/api/logging/v1alpha2/types.go b/pkg/api/logging/v1alpha2/types.go index 4f8c40fa2..0aadcd6d5 100644 --- a/pkg/api/logging/v1alpha2/types.go +++ b/pkg/api/logging/v1alpha2/types.go @@ -20,7 +20,7 @@ import ( "strconv" "time" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "kubesphere.io/kubesphere/pkg/simple/client/logging" ) diff --git a/pkg/api/logging/v1alpha2/types_test.go b/pkg/api/logging/v1alpha2/types_test.go index 69f7dc66c..199d493b2 100644 --- a/pkg/api/logging/v1alpha2/types_test.go +++ b/pkg/api/logging/v1alpha2/types_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "github.com/stretchr/testify/assert" ) diff --git a/pkg/api/metering/v1alpha1/types.go b/pkg/api/metering/v1alpha1/types.go index fb09eac0f..b87f22750 100644 --- a/pkg/api/metering/v1alpha1/types.go +++ b/pkg/api/metering/v1alpha1/types.go @@ -16,7 +16,7 @@ package v1alpha1 import ( "time" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "kubesphere.io/kubesphere/pkg/apiserver/query" model "kubesphere.io/kubesphere/pkg/models/monitoring" diff --git a/pkg/api/metering/v1alpha1/types_test.go b/pkg/api/metering/v1alpha1/types_test.go index b1f013bf1..1601e5102 100644 --- a/pkg/api/metering/v1alpha1/types_test.go +++ b/pkg/api/metering/v1alpha1/types_test.go @@ -5,7 +5,7 @@ import ( "net/http" "testing" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "github.com/stretchr/testify/assert" "kubesphere.io/kubesphere/pkg/simple/client/monitoring" diff --git a/pkg/api/utils.go b/pkg/api/utils.go index 1b1147649..bc5c720da 100644 --- a/pkg/api/utils.go +++ b/pkg/api/utils.go @@ -21,7 +21,7 @@ import ( "runtime" "strings" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/klog/v2" ) diff --git a/pkg/apiserver/apiserver.go b/pkg/apiserver/apiserver.go index bfdafffe2..1e4175e88 100644 --- a/pkg/apiserver/apiserver.go +++ b/pkg/apiserver/apiserver.go @@ -26,7 +26,7 @@ import ( "sync" "time" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/api/errors" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/pkg/apiserver/filters/dynamicresource.go b/pkg/apiserver/filters/dynamicresource.go index da26896b0..243baef31 100644 --- a/pkg/apiserver/filters/dynamicresource.go +++ b/pkg/apiserver/filters/dynamicresource.go @@ -4,7 +4,7 @@ import ( "fmt" "net/http" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apiserver/pkg/endpoints/handlers/responsewriters" diff --git a/pkg/apiserver/query/types.go b/pkg/apiserver/query/types.go index 4392c8e90..93ac40961 100644 --- a/pkg/apiserver/query/types.go +++ b/pkg/apiserver/query/types.go @@ -19,7 +19,7 @@ package query import ( "strconv" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/labels" "kubesphere.io/kubesphere/pkg/utils/sliceutil" diff --git a/pkg/apiserver/query/types_test.go b/pkg/apiserver/query/types_test.go index 1c7ee5dbb..ea720e16e 100644 --- a/pkg/apiserver/query/types_test.go +++ b/pkg/apiserver/query/types_test.go @@ -21,7 +21,7 @@ import ( "net/http" "testing" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "github.com/google/go-cmp/cmp" ) diff --git a/pkg/apiserver/runtime/runtime.go b/pkg/apiserver/runtime/runtime.go index dcdf3fdce..3b4a51bc6 100644 --- a/pkg/apiserver/runtime/runtime.go +++ b/pkg/apiserver/runtime/runtime.go @@ -17,7 +17,7 @@ limitations under the License. package runtime import ( - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/runtime/schema" ) diff --git a/pkg/kapis/alerting/v1/register.go b/pkg/kapis/alerting/v1/register.go index 2118d332c..b61478981 100644 --- a/pkg/kapis/alerting/v1/register.go +++ b/pkg/kapis/alerting/v1/register.go @@ -17,7 +17,7 @@ limitations under the License. package v1 import ( - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/runtime/schema" "kubesphere.io/kubesphere/pkg/kapis/generic" diff --git a/pkg/kapis/alerting/v2alpha1/handler.go b/pkg/kapis/alerting/v2alpha1/handler.go index 9270ae200..d19e84f0a 100644 --- a/pkg/kapis/alerting/v2alpha1/handler.go +++ b/pkg/kapis/alerting/v2alpha1/handler.go @@ -17,7 +17,7 @@ limitations under the License. package v2alpha1 import ( - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" promresourcesclient "github.com/prometheus-operator/prometheus-operator/pkg/client/versioned" "k8s.io/klog/v2" diff --git a/pkg/kapis/alerting/v2alpha1/register.go b/pkg/kapis/alerting/v2alpha1/register.go index 019259867..1a03ae13e 100644 --- a/pkg/kapis/alerting/v2alpha1/register.go +++ b/pkg/kapis/alerting/v2alpha1/register.go @@ -19,8 +19,8 @@ package v2alpha1 import ( "net/http" - "github.com/emicklei/go-restful" - restfulspec "github.com/emicklei/go-restful-openapi" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" promresourcesclient "github.com/prometheus-operator/prometheus-operator/pkg/client/versioned" "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/pkg/kapis/alerting/v2beta1/handler.go b/pkg/kapis/alerting/v2beta1/handler.go index 4170d8c04..81aa03a60 100644 --- a/pkg/kapis/alerting/v2beta1/handler.go +++ b/pkg/kapis/alerting/v2beta1/handler.go @@ -17,7 +17,7 @@ limitations under the License. package v2beta1 import ( - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "k8s.io/klog/v2" kapi "kubesphere.io/kubesphere/pkg/api" diff --git a/pkg/kapis/alerting/v2beta1/register.go b/pkg/kapis/alerting/v2beta1/register.go index fcf8331fe..58caf5af8 100644 --- a/pkg/kapis/alerting/v2beta1/register.go +++ b/pkg/kapis/alerting/v2beta1/register.go @@ -19,8 +19,8 @@ package v2beta1 import ( "net/http" - "github.com/emicklei/go-restful" - restfulspec "github.com/emicklei/go-restful-openapi" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" alertingv2beta1 "kubesphere.io/api/alerting/v2beta1" diff --git a/pkg/kapis/cluster/v1alpha1/handler.go b/pkg/kapis/cluster/v1alpha1/handler.go index 8a35531ad..d5b84aa58 100644 --- a/pkg/kapis/cluster/v1alpha1/handler.go +++ b/pkg/kapis/cluster/v1alpha1/handler.go @@ -27,7 +27,7 @@ import ( "strings" "time" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" diff --git a/pkg/kapis/cluster/v1alpha1/register.go b/pkg/kapis/cluster/v1alpha1/register.go index 955484819..efa9b8241 100644 --- a/pkg/kapis/cluster/v1alpha1/register.go +++ b/pkg/kapis/cluster/v1alpha1/register.go @@ -19,8 +19,8 @@ package v1alpha1 import ( "net/http" - "github.com/emicklei/go-restful" - restfulspec "github.com/emicklei/go-restful-openapi" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/runtime/schema" k8sinformers "k8s.io/client-go/informers" diff --git a/pkg/kapis/config/v1alpha2/register.go b/pkg/kapis/config/v1alpha2/register.go index 9352f4337..292103e78 100644 --- a/pkg/kapis/config/v1alpha2/register.go +++ b/pkg/kapis/config/v1alpha2/register.go @@ -17,7 +17,7 @@ limitations under the License. package v1alpha2 import ( - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/runtime/schema" "kubesphere.io/kubesphere/pkg/simple/client/gpu" diff --git a/pkg/kapis/devops/register.go b/pkg/kapis/devops/register.go index d40f16b5f..b755ac1d9 100644 --- a/pkg/kapis/devops/register.go +++ b/pkg/kapis/devops/register.go @@ -19,7 +19,7 @@ package devops import ( "strings" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/runtime/schema" "kubesphere.io/kubesphere/pkg/kapis/generic" diff --git a/pkg/kapis/devops/register_test.go b/pkg/kapis/devops/register_test.go index 7fa8106dd..b29c838eb 100644 --- a/pkg/kapis/devops/register_test.go +++ b/pkg/kapis/devops/register_test.go @@ -21,7 +21,7 @@ import ( "net/http/httptest" "testing" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "github.com/stretchr/testify/assert" ) diff --git a/pkg/kapis/edgeruntime/v1alpha1/register.go b/pkg/kapis/edgeruntime/v1alpha1/register.go index 7568852f1..060a50b36 100644 --- a/pkg/kapis/edgeruntime/v1alpha1/register.go +++ b/pkg/kapis/edgeruntime/v1alpha1/register.go @@ -17,7 +17,7 @@ limitations under the License. package v1 import ( - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/runtime/schema" "kubesphere.io/kubesphere/pkg/kapis/generic" diff --git a/pkg/kapis/gateway/v1alpha1/handler.go b/pkg/kapis/gateway/v1alpha1/handler.go index d6d66ad32..0d2be0ef0 100644 --- a/pkg/kapis/gateway/v1alpha1/handler.go +++ b/pkg/kapis/gateway/v1alpha1/handler.go @@ -20,7 +20,7 @@ import ( "fmt" "time" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" corev1 "k8s.io/api/core/v1" "k8s.io/apiserver/pkg/util/flushwriter" "k8s.io/client-go/kubernetes" diff --git a/pkg/kapis/gateway/v1alpha1/register.go b/pkg/kapis/gateway/v1alpha1/register.go index 46900d9aa..5e71fd53a 100644 --- a/pkg/kapis/gateway/v1alpha1/register.go +++ b/pkg/kapis/gateway/v1alpha1/register.go @@ -19,8 +19,8 @@ package v1alpha1 import ( "net/http" - "github.com/emicklei/go-restful" - restfulspec "github.com/emicklei/go-restful-openapi" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/kubernetes" "kubesphere.io/api/gateway/v1alpha1" diff --git a/pkg/kapis/generic/generic.go b/pkg/kapis/generic/generic.go index dc9b1600c..c4df87dc7 100644 --- a/pkg/kapis/generic/generic.go +++ b/pkg/kapis/generic/generic.go @@ -22,7 +22,7 @@ import ( "net/url" "strings" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/util/proxy" "k8s.io/klog/v2" diff --git a/pkg/kapis/generic/generic_test.go b/pkg/kapis/generic/generic_test.go index fb6b1d8c5..9ef1bea3f 100644 --- a/pkg/kapis/generic/generic_test.go +++ b/pkg/kapis/generic/generic_test.go @@ -21,7 +21,7 @@ import ( "net/url" "testing" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "github.com/google/go-cmp/cmp" ) diff --git a/pkg/kapis/iam/v1alpha2/handler.go b/pkg/kapis/iam/v1alpha2/handler.go index f91880049..6d5bf723f 100644 --- a/pkg/kapis/iam/v1alpha2/handler.go +++ b/pkg/kapis/iam/v1alpha2/handler.go @@ -25,7 +25,7 @@ import ( "kubesphere.io/kubesphere/pkg/apiserver/request" "kubesphere.io/kubesphere/pkg/models/auth" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" rbacv1 "k8s.io/api/rbac/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/klog/v2" diff --git a/pkg/kapis/iam/v1alpha2/register.go b/pkg/kapis/iam/v1alpha2/register.go index 8c5c5025b..a878950f6 100644 --- a/pkg/kapis/iam/v1alpha2/register.go +++ b/pkg/kapis/iam/v1alpha2/register.go @@ -21,8 +21,8 @@ import ( "kubesphere.io/kubesphere/pkg/apiserver/authorization/authorizer" - "github.com/emicklei/go-restful" - restfulspec "github.com/emicklei/go-restful-openapi" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" rbacv1 "k8s.io/api/rbac/v1" v1 "k8s.io/api/rbac/v1" "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/pkg/kapis/kubeedge/v1alpha1/register.go b/pkg/kapis/kubeedge/v1alpha1/register.go index 548d2d86c..211d63d61 100644 --- a/pkg/kapis/kubeedge/v1alpha1/register.go +++ b/pkg/kapis/kubeedge/v1alpha1/register.go @@ -17,7 +17,7 @@ limitations under the License. package v1 import ( - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/runtime/schema" "kubesphere.io/kubesphere/pkg/kapis/generic" diff --git a/pkg/kapis/metering/v1alpha1/handler.go b/pkg/kapis/metering/v1alpha1/handler.go index 6a5ed8d3e..63f14cfaf 100644 --- a/pkg/kapis/metering/v1alpha1/handler.go +++ b/pkg/kapis/metering/v1alpha1/handler.go @@ -19,7 +19,7 @@ package v1alpha1 import ( - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "k8s.io/client-go/kubernetes" runtimeclient "sigs.k8s.io/controller-runtime/pkg/client" diff --git a/pkg/kapis/metering/v1alpha1/register.go b/pkg/kapis/metering/v1alpha1/register.go index f78b5f9c4..ed14d2349 100644 --- a/pkg/kapis/metering/v1alpha1/register.go +++ b/pkg/kapis/metering/v1alpha1/register.go @@ -20,8 +20,8 @@ import ( "kubesphere.io/kubesphere/pkg/models/openpitrix" - "github.com/emicklei/go-restful" - restfulspec "github.com/emicklei/go-restful-openapi" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/kubernetes" "sigs.k8s.io/controller-runtime/pkg/cache" diff --git a/pkg/kapis/monitoring/v1alpha3/handler.go b/pkg/kapis/monitoring/v1alpha3/handler.go index 86187f9a3..8219567d3 100644 --- a/pkg/kapis/monitoring/v1alpha3/handler.go +++ b/pkg/kapis/monitoring/v1alpha3/handler.go @@ -31,7 +31,7 @@ import ( "kubesphere.io/kubesphere/pkg/models/openpitrix" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" runtimeclient "sigs.k8s.io/controller-runtime/pkg/client" diff --git a/pkg/kapis/monitoring/v1alpha3/helper.go b/pkg/kapis/monitoring/v1alpha3/helper.go index f08614099..df4533bc8 100644 --- a/pkg/kapis/monitoring/v1alpha3/helper.go +++ b/pkg/kapis/monitoring/v1alpha3/helper.go @@ -29,7 +29,7 @@ import ( "github.com/jszwec/csvutil" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "github.com/pkg/errors" corev1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/kapis/monitoring/v1alpha3/meter.go b/pkg/kapis/monitoring/v1alpha3/meter.go index e8d509c48..89ddb837f 100644 --- a/pkg/kapis/monitoring/v1alpha3/meter.go +++ b/pkg/kapis/monitoring/v1alpha3/meter.go @@ -20,7 +20,7 @@ import ( "kubesphere.io/kubesphere/pkg/models/openpitrix" "kubesphere.io/kubesphere/pkg/server/params" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/klog/v2" diff --git a/pkg/kapis/monitoring/v1alpha3/register.go b/pkg/kapis/monitoring/v1alpha3/register.go index acfbfada7..103596579 100644 --- a/pkg/kapis/monitoring/v1alpha3/register.go +++ b/pkg/kapis/monitoring/v1alpha3/register.go @@ -22,8 +22,8 @@ import ( monitoringdashboardv1alpha2 "kubesphere.io/monitoring-dashboard/api/v1alpha2" - "github.com/emicklei/go-restful" - restfulspec "github.com/emicklei/go-restful-openapi" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/kubernetes" diff --git a/pkg/kapis/network/v1alpha2/handler.go b/pkg/kapis/network/v1alpha2/handler.go index 5a6476b73..ad2b48eb4 100644 --- a/pkg/kapis/network/v1alpha2/handler.go +++ b/pkg/kapis/network/v1alpha2/handler.go @@ -22,7 +22,7 @@ import ( "net/http" "net/url" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "k8s.io/klog/v2" "kubesphere.io/kubesphere/pkg/api" diff --git a/pkg/kapis/network/v1alpha2/register.go b/pkg/kapis/network/v1alpha2/register.go index 8a8c38f32..e95a6fd44 100644 --- a/pkg/kapis/network/v1alpha2/register.go +++ b/pkg/kapis/network/v1alpha2/register.go @@ -19,8 +19,8 @@ package v1alpha2 import ( "net/http" - restful "github.com/emicklei/go-restful" - restfulspec "github.com/emicklei/go-restful-openapi" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/runtime/schema" "kubesphere.io/kubesphere/pkg/apiserver/runtime" diff --git a/pkg/kapis/notification/v1/register.go b/pkg/kapis/notification/v1/register.go index 10b60af08..d48d2c5c3 100644 --- a/pkg/kapis/notification/v1/register.go +++ b/pkg/kapis/notification/v1/register.go @@ -17,7 +17,7 @@ limitations under the License. package v1 import ( - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/runtime/schema" "kubesphere.io/kubesphere/pkg/kapis/generic" diff --git a/pkg/kapis/notification/v2beta1/handler.go b/pkg/kapis/notification/v2beta1/handler.go index 36a8eeaa4..e6cc6f49e 100644 --- a/pkg/kapis/notification/v2beta1/handler.go +++ b/pkg/kapis/notification/v2beta1/handler.go @@ -17,7 +17,7 @@ limitations under the License. package v2beta1 import ( - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/client-go/kubernetes" "k8s.io/klog/v2" diff --git a/pkg/kapis/notification/v2beta1/register.go b/pkg/kapis/notification/v2beta1/register.go index d1af290c9..05754bb68 100644 --- a/pkg/kapis/notification/v2beta1/register.go +++ b/pkg/kapis/notification/v2beta1/register.go @@ -21,8 +21,8 @@ package v2beta1 import ( "net/http" - "github.com/emicklei/go-restful" - openapi "github.com/emicklei/go-restful-openapi" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/kubernetes" @@ -37,7 +37,7 @@ import ( const ( GroupName = "notification.kubesphere.io" - KeyOpenAPITags = openapi.KeyOpenAPITags + KeyOpenAPITags = restfulspec.KeyOpenAPITags ) var GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v2beta1"} diff --git a/pkg/kapis/notification/v2beta2/handler.go b/pkg/kapis/notification/v2beta2/handler.go index 669b893a8..efafac92d 100644 --- a/pkg/kapis/notification/v2beta2/handler.go +++ b/pkg/kapis/notification/v2beta2/handler.go @@ -18,7 +18,7 @@ package v2beta2 import ( "io" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/client-go/kubernetes" "k8s.io/klog/v2" diff --git a/pkg/kapis/notification/v2beta2/register.go b/pkg/kapis/notification/v2beta2/register.go index 8f57aa4b3..039c2de48 100644 --- a/pkg/kapis/notification/v2beta2/register.go +++ b/pkg/kapis/notification/v2beta2/register.go @@ -21,8 +21,8 @@ package v2beta2 import ( "net/http" - "github.com/emicklei/go-restful" - openapi "github.com/emicklei/go-restful-openapi" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/kubernetes" @@ -38,7 +38,7 @@ import ( const ( GroupName = "notification.kubesphere.io" - KeyOpenAPITags = openapi.KeyOpenAPITags + KeyOpenAPITags = restfulspec.KeyOpenAPITags ) var GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v2beta2"} diff --git a/pkg/kapis/oauth/handler.go b/pkg/kapis/oauth/handler.go index a9bfcc70a..2703b2e27 100644 --- a/pkg/kapis/oauth/handler.go +++ b/pkg/kapis/oauth/handler.go @@ -23,7 +23,7 @@ import ( "strings" "time" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "github.com/golang-jwt/jwt/v4" "gopkg.in/square/go-jose.v2" apierrors "k8s.io/apimachinery/pkg/api/errors" diff --git a/pkg/kapis/oauth/register.go b/pkg/kapis/oauth/register.go index e52497e7f..1cb8d7707 100644 --- a/pkg/kapis/oauth/register.go +++ b/pkg/kapis/oauth/register.go @@ -21,8 +21,8 @@ import ( "kubesphere.io/kubesphere/pkg/apiserver/authentication" - "github.com/emicklei/go-restful" - restfulspec "github.com/emicklei/go-restful-openapi" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" "kubesphere.io/kubesphere/pkg/api" "kubesphere.io/kubesphere/pkg/apiserver/authentication/oauth" diff --git a/pkg/kapis/openpitrix/v1/handler.go b/pkg/kapis/openpitrix/v1/handler.go index ceb50895c..30ba2e210 100644 --- a/pkg/kapis/openpitrix/v1/handler.go +++ b/pkg/kapis/openpitrix/v1/handler.go @@ -23,9 +23,7 @@ import ( "strings" "time" - "kubesphere.io/kubesphere/pkg/utils/clusterclient" - - restful "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -44,6 +42,7 @@ import ( "kubesphere.io/kubesphere/pkg/server/params" openpitrixoptions "kubesphere.io/kubesphere/pkg/simple/client/openpitrix" "kubesphere.io/kubesphere/pkg/simple/client/s3" + "kubesphere.io/kubesphere/pkg/utils/clusterclient" "kubesphere.io/kubesphere/pkg/utils/idutils" "kubesphere.io/kubesphere/pkg/utils/stringutils" ) diff --git a/pkg/kapis/openpitrix/v1/register.go b/pkg/kapis/openpitrix/v1/register.go index 53b23c4ad..a77f11fb1 100644 --- a/pkg/kapis/openpitrix/v1/register.go +++ b/pkg/kapis/openpitrix/v1/register.go @@ -16,8 +16,8 @@ package v1 import ( "net/http" - restful "github.com/emicklei/go-restful" - restfulspec "github.com/emicklei/go-restful-openapi" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/runtime/schema" "kubesphere.io/kubesphere/pkg/api" diff --git a/pkg/kapis/openpitrix/v2alpha1/handler.go b/pkg/kapis/openpitrix/v2alpha1/handler.go index 9e911aa0d..ac3ece75b 100644 --- a/pkg/kapis/openpitrix/v2alpha1/handler.go +++ b/pkg/kapis/openpitrix/v2alpha1/handler.go @@ -14,7 +14,7 @@ limitations under the License. package v2alpha1 import ( - restful "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/klog/v2" diff --git a/pkg/kapis/openpitrix/v2alpha1/register.go b/pkg/kapis/openpitrix/v2alpha1/register.go index 1e421e803..2ee38310e 100644 --- a/pkg/kapis/openpitrix/v2alpha1/register.go +++ b/pkg/kapis/openpitrix/v2alpha1/register.go @@ -16,8 +16,8 @@ package v2alpha1 import ( "net/http" - restful "github.com/emicklei/go-restful" - restfulspec "github.com/emicklei/go-restful-openapi" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/runtime/schema" "kubesphere.io/api/application/v1alpha1" diff --git a/pkg/kapis/operations/v1alpha2/handler.go b/pkg/kapis/operations/v1alpha2/handler.go index 18c59389c..b531a7c51 100644 --- a/pkg/kapis/operations/v1alpha2/handler.go +++ b/pkg/kapis/operations/v1alpha2/handler.go @@ -20,7 +20,7 @@ import ( "fmt" "net/http" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" k8serr "k8s.io/apimachinery/pkg/api/errors" "k8s.io/client-go/kubernetes" diff --git a/pkg/kapis/operations/v1alpha2/register.go b/pkg/kapis/operations/v1alpha2/register.go index 104dd0e0a..46556604c 100644 --- a/pkg/kapis/operations/v1alpha2/register.go +++ b/pkg/kapis/operations/v1alpha2/register.go @@ -19,7 +19,7 @@ package v1alpha2 import ( "net/http" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/kubernetes" diff --git a/pkg/kapis/resources/v1alpha2/handler.go b/pkg/kapis/resources/v1alpha2/handler.go index d962a92eb..dbb5384c8 100644 --- a/pkg/kapis/resources/v1alpha2/handler.go +++ b/pkg/kapis/resources/v1alpha2/handler.go @@ -22,7 +22,7 @@ import ( "strconv" "strings" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" v1 "k8s.io/api/core/v1" k8serr "k8s.io/apimachinery/pkg/api/errors" "k8s.io/client-go/kubernetes" diff --git a/pkg/kapis/resources/v1alpha2/register.go b/pkg/kapis/resources/v1alpha2/register.go index efe881b10..6c41c3aee 100644 --- a/pkg/kapis/resources/v1alpha2/register.go +++ b/pkg/kapis/resources/v1alpha2/register.go @@ -19,8 +19,8 @@ package v1alpha2 import ( "net/http" - "github.com/emicklei/go-restful" - restfulspec "github.com/emicklei/go-restful-openapi" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/pkg/kapis/resources/v1alpha3/handler.go b/pkg/kapis/resources/v1alpha3/handler.go index 4555a8e4a..587c7314c 100644 --- a/pkg/kapis/resources/v1alpha3/handler.go +++ b/pkg/kapis/resources/v1alpha3/handler.go @@ -21,7 +21,7 @@ import ( "net/http" "strings" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/klog/v2" diff --git a/pkg/kapis/resources/v1alpha3/handler_test.go b/pkg/kapis/resources/v1alpha3/handler_test.go index ad175c9ac..7e9df6281 100644 --- a/pkg/kapis/resources/v1alpha3/handler_test.go +++ b/pkg/kapis/resources/v1alpha3/handler_test.go @@ -25,7 +25,7 @@ import ( "testing" "unsafe" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "k8s.io/klog/v2" "github.com/google/go-cmp/cmp" diff --git a/pkg/kapis/resources/v1alpha3/register.go b/pkg/kapis/resources/v1alpha3/register.go index 0de95ac14..f5d47093a 100644 --- a/pkg/kapis/resources/v1alpha3/register.go +++ b/pkg/kapis/resources/v1alpha3/register.go @@ -17,8 +17,8 @@ limitations under the License. package v1alpha3 import ( - "github.com/emicklei/go-restful" - restfulspec "github.com/emicklei/go-restful-openapi" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime/schema" "sigs.k8s.io/controller-runtime/pkg/cache" diff --git a/pkg/kapis/servicemesh/metrics/install/install.go b/pkg/kapis/servicemesh/metrics/install/install.go index c524d569b..acfb20684 100644 --- a/pkg/kapis/servicemesh/metrics/install/install.go +++ b/pkg/kapis/servicemesh/metrics/install/install.go @@ -17,7 +17,7 @@ limitations under the License. package install import ( - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" urlruntime "k8s.io/apimachinery/pkg/util/runtime" "kubesphere.io/kubesphere/pkg/apiserver/runtime" diff --git a/pkg/kapis/servicemesh/metrics/v1alpha2/handler.go b/pkg/kapis/servicemesh/metrics/v1alpha2/handler.go index 09008c7ba..9628742a4 100644 --- a/pkg/kapis/servicemesh/metrics/v1alpha2/handler.go +++ b/pkg/kapis/servicemesh/metrics/v1alpha2/handler.go @@ -23,7 +23,7 @@ import ( "io" "net/http" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" "k8s.io/klog/v2" diff --git a/pkg/kapis/servicemesh/metrics/v1alpha2/handler_test.go b/pkg/kapis/servicemesh/metrics/v1alpha2/handler_test.go index 988024293..e49217102 100644 --- a/pkg/kapis/servicemesh/metrics/v1alpha2/handler_test.go +++ b/pkg/kapis/servicemesh/metrics/v1alpha2/handler_test.go @@ -8,7 +8,7 @@ import ( "net/http/httptest" "testing" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" fakek8s "k8s.io/client-go/kubernetes/fake" diff --git a/pkg/kapis/servicemesh/metrics/v1alpha2/register.go b/pkg/kapis/servicemesh/metrics/v1alpha2/register.go index fae7c1536..6f84b1fbf 100644 --- a/pkg/kapis/servicemesh/metrics/v1alpha2/register.go +++ b/pkg/kapis/servicemesh/metrics/v1alpha2/register.go @@ -19,8 +19,8 @@ package v1alpha2 import ( "net/http" - "github.com/emicklei/go-restful" - restfulspec "github.com/emicklei/go-restful-openapi" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/kubernetes" diff --git a/pkg/kapis/tenant/v1alpha2/handler.go b/pkg/kapis/tenant/v1alpha2/handler.go index 4928bc7ab..adfd470de 100644 --- a/pkg/kapis/tenant/v1alpha2/handler.go +++ b/pkg/kapis/tenant/v1alpha2/handler.go @@ -20,7 +20,7 @@ import ( "encoding/json" "fmt" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/kapis/tenant/v1alpha2/metering.go b/pkg/kapis/tenant/v1alpha2/metering.go index 164d62352..2c3c38e9f 100644 --- a/pkg/kapis/tenant/v1alpha2/metering.go +++ b/pkg/kapis/tenant/v1alpha2/metering.go @@ -16,7 +16,7 @@ package v1alpha2 import ( "fmt" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "k8s.io/klog/v2" "strconv" diff --git a/pkg/kapis/tenant/v1alpha2/register.go b/pkg/kapis/tenant/v1alpha2/register.go index cb9fcd471..b1edd39b5 100644 --- a/pkg/kapis/tenant/v1alpha2/register.go +++ b/pkg/kapis/tenant/v1alpha2/register.go @@ -19,8 +19,8 @@ package v1alpha2 import ( "net/http" - "github.com/emicklei/go-restful" - restfulspec "github.com/emicklei/go-restful-openapi" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/kubernetes" diff --git a/pkg/kapis/tenant/v1alpha3/handler.go b/pkg/kapis/tenant/v1alpha3/handler.go index c8f9dd56b..d7465ea72 100644 --- a/pkg/kapis/tenant/v1alpha3/handler.go +++ b/pkg/kapis/tenant/v1alpha3/handler.go @@ -19,7 +19,7 @@ package v1alpha3 import ( "fmt" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/client-go/kubernetes" "k8s.io/klog/v2" diff --git a/pkg/kapis/tenant/v1alpha3/register.go b/pkg/kapis/tenant/v1alpha3/register.go index d514670bb..6c3b95138 100644 --- a/pkg/kapis/tenant/v1alpha3/register.go +++ b/pkg/kapis/tenant/v1alpha3/register.go @@ -19,8 +19,8 @@ package v1alpha3 import ( "net/http" - "github.com/emicklei/go-restful" - restfulspec "github.com/emicklei/go-restful-openapi" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/kubernetes" tenantv1alpha1 "kubesphere.io/api/tenant/v1alpha1" diff --git a/pkg/kapis/terminal/v1alpha2/handler.go b/pkg/kapis/terminal/v1alpha2/handler.go index 2d8c4590c..40b30bef2 100644 --- a/pkg/kapis/terminal/v1alpha2/handler.go +++ b/pkg/kapis/terminal/v1alpha2/handler.go @@ -24,7 +24,7 @@ import ( "kubesphere.io/kubesphere/pkg/apiserver/authorization/authorizer" requestctx "kubesphere.io/kubesphere/pkg/apiserver/request" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "github.com/gorilla/websocket" "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" diff --git a/pkg/kapis/terminal/v1alpha2/register.go b/pkg/kapis/terminal/v1alpha2/register.go index ff23ae9d4..d68632c80 100644 --- a/pkg/kapis/terminal/v1alpha2/register.go +++ b/pkg/kapis/terminal/v1alpha2/register.go @@ -17,8 +17,8 @@ limitations under the License. package v1alpha2 import ( - "github.com/emicklei/go-restful" - restfulspec "github.com/emicklei/go-restful-openapi" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" diff --git a/pkg/kapis/version/register.go b/pkg/kapis/version/register.go index 86a59f5c8..8365b01ba 100644 --- a/pkg/kapis/version/register.go +++ b/pkg/kapis/version/register.go @@ -17,7 +17,7 @@ limitations under the License. package version import ( - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/discovery" "k8s.io/klog/v2" diff --git a/pkg/models/devops/project_pipeline_sonar_handler.go b/pkg/models/devops/project_pipeline_sonar_handler.go index 68f0339b6..047996fbb 100644 --- a/pkg/models/devops/project_pipeline_sonar_handler.go +++ b/pkg/models/devops/project_pipeline_sonar_handler.go @@ -19,7 +19,7 @@ package devops import ( "net/http" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "k8s.io/klog/v2" "kubesphere.io/kubesphere/pkg/server/errors" diff --git a/pkg/models/devops/s2ibinary_handler.go b/pkg/models/devops/s2ibinary_handler.go index f2d93ab29..d849bb3ef 100644 --- a/pkg/models/devops/s2ibinary_handler.go +++ b/pkg/models/devops/s2ibinary_handler.go @@ -26,7 +26,7 @@ import ( "code.cloudfoundry.org/bytefmt" "github.com/aws/aws-sdk-go/aws/awserr" awsS3 "github.com/aws/aws-sdk-go/service/s3" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/util/retry" "k8s.io/klog/v2" diff --git a/pkg/models/notification/notification.go b/pkg/models/notification/notification.go index bae8d2cef..15ad57a52 100644 --- a/pkg/models/notification/notification.go +++ b/pkg/models/notification/notification.go @@ -26,7 +26,7 @@ import ( "k8s.io/apimachinery/pkg/types" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/meta" diff --git a/pkg/models/registries/manifest.go b/pkg/models/registries/manifest.go index 194cd0f56..b0d5b6c79 100644 --- a/pkg/models/registries/manifest.go +++ b/pkg/models/registries/manifest.go @@ -22,7 +22,7 @@ import ( "net/http" "github.com/docker/distribution/manifest/schema2" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "k8s.io/klog/v2" ) diff --git a/pkg/models/registries/registries.go b/pkg/models/registries/registries.go index 07126ccef..6200e02fa 100644 --- a/pkg/models/registries/registries.go +++ b/pkg/models/registries/registries.go @@ -25,7 +25,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/client" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" corev1 "k8s.io/api/core/v1" "k8s.io/client-go/informers" "k8s.io/klog/v2" diff --git a/pkg/server/errors/errors.go b/pkg/server/errors/errors.go index 7bc0ebb45..6c90bfcbb 100644 --- a/pkg/server/errors/errors.go +++ b/pkg/server/errors/errors.go @@ -20,7 +20,7 @@ import ( "fmt" "net/http" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" ) type Error struct { diff --git a/pkg/server/healthz/healthz.go b/pkg/server/healthz/healthz.go index 5256c7026..8a67cf920 100644 --- a/pkg/server/healthz/healthz.go +++ b/pkg/server/healthz/healthz.go @@ -25,7 +25,7 @@ import ( "strings" "sync" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/apiserver/pkg/server/httplog" "k8s.io/klog/v2" diff --git a/pkg/server/params/params.go b/pkg/server/params/params.go index 6403bf8cc..c76ce5a12 100644 --- a/pkg/server/params/params.go +++ b/pkg/server/params/params.go @@ -22,7 +22,7 @@ import ( "strconv" "strings" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" ) const ( diff --git a/pkg/server/params/params_test.go b/pkg/server/params/params_test.go index 33c60d6a9..5b77419eb 100644 --- a/pkg/server/params/params_test.go +++ b/pkg/server/params/params_test.go @@ -24,7 +24,7 @@ import ( "gotest.tools/assert" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" ) func TestParseConditions(t *testing.T) { diff --git a/pkg/simple/client/devops/fake/fakedevops.go b/pkg/simple/client/devops/fake/fakedevops.go index 3eaaece01..3c4ae4753 100644 --- a/pkg/simple/client/devops/fake/fakedevops.go +++ b/pkg/simple/client/devops/fake/fakedevops.go @@ -23,7 +23,7 @@ import ( "net/url" "strings" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" v1 "k8s.io/api/core/v1" devopsv1alpha3 "kubesphere.io/api/devops/v1alpha3" diff --git a/pkg/simple/client/devops/jenkins/build.go b/pkg/simple/client/devops/jenkins/build.go index 26e0b3767..e76f735b5 100644 --- a/pkg/simple/client/devops/jenkins/build.go +++ b/pkg/simple/client/devops/jenkins/build.go @@ -22,7 +22,7 @@ import ( "strconv" "time" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "kubesphere.io/kubesphere/pkg/simple/client/devops" ) diff --git a/pkg/simple/client/devops/jenkins/credential.go b/pkg/simple/client/devops/jenkins/credential.go index 97871b3f2..74a1b6c2e 100644 --- a/pkg/simple/client/devops/jenkins/credential.go +++ b/pkg/simple/client/devops/jenkins/credential.go @@ -19,7 +19,7 @@ import ( "net/http" "strconv" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" v1 "k8s.io/api/core/v1" "k8s.io/klog/v2" diff --git a/pkg/simple/client/devops/jenkins/project.go b/pkg/simple/client/devops/jenkins/project.go index 51a26564f..0f87dbbd0 100644 --- a/pkg/simple/client/devops/jenkins/project.go +++ b/pkg/simple/client/devops/jenkins/project.go @@ -17,7 +17,7 @@ limitations under the License. package jenkins import ( - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "k8s.io/klog/v2" "kubesphere.io/kubesphere/pkg/simple/client/devops" diff --git a/pkg/simple/client/devops/jenkins/project_pipeline.go b/pkg/simple/client/devops/jenkins/project_pipeline.go index f46bf75b3..bd9843efd 100644 --- a/pkg/simple/client/devops/jenkins/project_pipeline.go +++ b/pkg/simple/client/devops/jenkins/project_pipeline.go @@ -20,7 +20,7 @@ import ( "fmt" "net/http" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "k8s.io/klog/v2" devopsv1alpha3 "kubesphere.io/api/devops/v1alpha3" diff --git a/pkg/utils/metrics/metrics.go b/pkg/utils/metrics/metrics.go index b8d4d65e9..bf10311a0 100644 --- a/pkg/utils/metrics/metrics.go +++ b/pkg/utils/metrics/metrics.go @@ -21,7 +21,7 @@ import ( "net/http" "sync" - "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" apimachineryversion "k8s.io/apimachinery/pkg/version" diff --git a/staging/src/kubesphere.io/api/go.mod b/staging/src/kubesphere.io/api/go.mod index d96e29714..5774618ef 100644 --- a/staging/src/kubesphere.io/api/go.mod +++ b/staging/src/kubesphere.io/api/go.mod @@ -34,7 +34,7 @@ require ( github.com/dennwc/varint v1.0.0 // indirect github.com/docker/docker v20.10.24+incompatible // indirect github.com/edsrzf/mmap-go v1.1.0 // indirect - github.com/emicklei/go-restful/v3 v3.10.1 // indirect + github.com/emicklei/go-restful/v3 v3.10.2 // indirect github.com/evanphx/json-patch v5.6.0+incompatible // indirect github.com/evanphx/json-patch/v5 v5.6.0 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect diff --git a/staging/src/kubesphere.io/api/go.sum b/staging/src/kubesphere.io/api/go.sum index f1468a6e5..c381a6bf5 100644 --- a/staging/src/kubesphere.io/api/go.sum +++ b/staging/src/kubesphere.io/api/go.sum @@ -151,8 +151,8 @@ github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkg github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful v2.11.2-0.20200112161605-a7c079c43d51+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= -github.com/emicklei/go-restful/v3 v3.10.1 h1:rc42Y5YTp7Am7CS630D7JmhRjq4UlEUuEKfrDac4bSQ= -github.com/emicklei/go-restful/v3 v3.10.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful/v3 v3.10.2 h1:hIovbnmBTLjHXkqEBUz3HGpXZdM7ZrE9fJIZIqlJLqE= +github.com/emicklei/go-restful/v3 v3.10.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= diff --git a/staging/src/kubesphere.io/client-go/go.mod b/staging/src/kubesphere.io/client-go/go.mod index 9ac13cef2..d51f4cc8e 100644 --- a/staging/src/kubesphere.io/client-go/go.mod +++ b/staging/src/kubesphere.io/client-go/go.mod @@ -13,7 +13,7 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/emicklei/go-restful/v3 v3.10.1 // indirect + github.com/emicklei/go-restful/v3 v3.10.2 // indirect github.com/go-logr/logr v1.2.3 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect github.com/go-openapi/jsonreference v0.20.2 // indirect diff --git a/staging/src/kubesphere.io/client-go/go.sum b/staging/src/kubesphere.io/client-go/go.sum index 706ca17c6..4cf6f978e 100644 --- a/staging/src/kubesphere.io/client-go/go.sum +++ b/staging/src/kubesphere.io/client-go/go.sum @@ -15,8 +15,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= -github.com/emicklei/go-restful/v3 v3.10.1 h1:rc42Y5YTp7Am7CS630D7JmhRjq4UlEUuEKfrDac4bSQ= -github.com/emicklei/go-restful/v3 v3.10.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful/v3 v3.10.2 h1:hIovbnmBTLjHXkqEBUz3HGpXZdM7ZrE9fJIZIqlJLqE= +github.com/emicklei/go-restful/v3 v3.10.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= diff --git a/staging/src/kubesphere.io/utils/go.mod b/staging/src/kubesphere.io/utils/go.mod index dd4fd906e..5f79f1eb3 100644 --- a/staging/src/kubesphere.io/utils/go.mod +++ b/staging/src/kubesphere.io/utils/go.mod @@ -41,7 +41,7 @@ require ( github.com/docker/go-metrics v0.0.1 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect - github.com/emicklei/go-restful/v3 v3.10.1 // indirect + github.com/emicklei/go-restful/v3 v3.10.2 // indirect github.com/evanphx/json-patch v5.6.0+incompatible // indirect github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect github.com/fatih/color v1.13.0 // indirect diff --git a/staging/src/kubesphere.io/utils/go.sum b/staging/src/kubesphere.io/utils/go.sum index c8902974c..b9d98a410 100644 --- a/staging/src/kubesphere.io/utils/go.sum +++ b/staging/src/kubesphere.io/utils/go.sum @@ -95,8 +95,8 @@ github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 h1:UhxFibDNY/bfvqU github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153 h1:yUdfgN0XgIJw7foRItutHYUIhlcKzcSf5vDpdhQAKTc= -github.com/emicklei/go-restful/v3 v3.10.1 h1:rc42Y5YTp7Am7CS630D7JmhRjq4UlEUuEKfrDac4bSQ= -github.com/emicklei/go-restful/v3 v3.10.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful/v3 v3.10.2 h1:hIovbnmBTLjHXkqEBUz3HGpXZdM7ZrE9fJIZIqlJLqE= +github.com/emicklei/go-restful/v3 v3.10.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= diff --git a/tools/cmd/doc-gen/main.go b/tools/cmd/doc-gen/main.go index 6c099bf1e..1ec07ebe7 100644 --- a/tools/cmd/doc-gen/main.go +++ b/tools/cmd/doc-gen/main.go @@ -23,7 +23,7 @@ import ( "log" "os" - restfulspec "github.com/emicklei/go-restful-openapi" + restfulspec "github.com/emicklei/go-restful-openapi/v2" "github.com/go-openapi/loads" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" diff --git a/vendor/github.com/emicklei/go-restful-openapi/.travis.yml b/vendor/github.com/emicklei/go-restful-openapi/.travis.yml deleted file mode 100644 index c74e4fa57..000000000 --- a/vendor/github.com/emicklei/go-restful-openapi/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: go - -go: - - 1.x \ No newline at end of file diff --git a/vendor/github.com/emicklei/go-restful-openapi/.gitignore b/vendor/github.com/emicklei/go-restful-openapi/v2/.gitignore similarity index 72% rename from vendor/github.com/emicklei/go-restful-openapi/.gitignore rename to vendor/github.com/emicklei/go-restful-openapi/v2/.gitignore index f7a9a6520..1f46e8812 100644 --- a/vendor/github.com/emicklei/go-restful-openapi/.gitignore +++ b/vendor/github.com/emicklei/go-restful-openapi/v2/.gitignore @@ -1 +1,2 @@ examples/examples +.vscode \ No newline at end of file diff --git a/vendor/github.com/emicklei/go-restful-openapi/v2/.golangci.yml b/vendor/github.com/emicklei/go-restful-openapi/v2/.golangci.yml new file mode 100644 index 000000000..f92227518 --- /dev/null +++ b/vendor/github.com/emicklei/go-restful-openapi/v2/.golangci.yml @@ -0,0 +1,103 @@ +# This file contains all available configuration options +# with their default values. + +# options for analysis running +run: + # timeout for analysis, e.g. 30s, 5m, default is 1m + deadline: 5m + + # exit code when at least one issue was found, default is 1 + issues-exit-code: 1 + + # include test files or not, default is true + tests: true + + # which dirs to skip: they won't be analyzed; + # can use regexp here: generated.*, regexp is applied on full path; + # default value is empty list, but next dirs are always skipped independently + # from this option's value: + # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ + skip-dirs: + + # which files to skip: they will be analyzed, but issues from them + # won't be reported. Default value is empty list, but there is + # no need to include all autogenerated files, we confidently recognize + # autogenerated files. If it's not please let us know. + skip-files: + + # whether to hide "congrats" message if no issues were found, + # default is false (show "congrats" message by default). + # set this option to true to print nothing if no issues were found. + silent: true + +# build-tags: +# - mandrill +# - test + +# output configuration options +output: + # colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number" + format: line-number + + # print lines of code with issue, default is true + print-issued-lines: true + + # print linter name in the end of issue text, default is true + print-linter-name: true + +linters: + enable-all: true + disable: + - gochecknoglobals + - gochecknoinits + - lll + - dupl + - wsl + - funlen + - gocognit + - testpackage + - gomnd + - goerr113 + - nestif + - interfacer + - godot + - unparam + - nlreturn + - wrapcheck + - exhaustivestruct + - errorlint + # todo enable as much as possible linters below + - paralleltest + - unused + - govet + - gosimple + - exhaustive + - whitespace + - structcheck + - misspell + - golint + - goheader + - stylecheck + - gofumpt + - gofmt + - godox + - gocyclo + - gocritic + - goconst + - goimports + - gci + - errcheck + - deadcode + fast: false + +linters-settings: + govet: + check-shadowing: true + golint: + report-comments: true + +issues: + max-same-issues: 20 + exclude: + - ^G104 + - ^G501 diff --git a/vendor/github.com/emicklei/go-restful-openapi/v2/.travis.yml b/vendor/github.com/emicklei/go-restful-openapi/v2/.travis.yml new file mode 100644 index 000000000..e5b65c3a7 --- /dev/null +++ b/vendor/github.com/emicklei/go-restful-openapi/v2/.travis.yml @@ -0,0 +1,13 @@ +language: go + +go: + - 1.13 + +before_install: + - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.33.0 + +script: + - go mod vendor + - go mod download +# - make lint-ci + - make test diff --git a/vendor/github.com/emicklei/go-restful-openapi/CHANGES.md b/vendor/github.com/emicklei/go-restful-openapi/v2/CHANGES.md similarity index 57% rename from vendor/github.com/emicklei/go-restful-openapi/CHANGES.md rename to vendor/github.com/emicklei/go-restful-openapi/v2/CHANGES.md index 7bd1eb805..68f9a6a8d 100644 --- a/vendor/github.com/emicklei/go-restful-openapi/CHANGES.md +++ b/vendor/github.com/emicklei/go-restful-openapi/v2/CHANGES.md @@ -2,6 +2,52 @@ # v2+ versions are using the Go module of go-restful v3+ + +## v2.9.1 + + - fix set array data format (#96) + +## v2.9.0 + + - Add property x-go-name support (#90) + - Add support to set swagger Schemes field (#91) + +## v2.8.0 + +[2022-01-04] + +- refine and fix GoLowerCamelCasedNameHandler bug (#88) +- Add missing fields of response header object (#89) +- support generate field name with config (#86) + +Thanks again to slow-zhang and Sergey Vilgelm + +## v2.7.0 + +[2021-12-08] + +- fix some typos (#85) +- use PossibleValues in favor of AllowedValues (#84) +- PostBuildSwaggerSchema handler for each model (#83) +- Use int64 format for time.Duration type (#82) + +Special thanks to contributions of Sergey Vilgelm + +## [2021-09-20] v2.6.0 + +- feat(parameter): adds additional openapi mappings (#74, robbie@robnrob.com) + +## [2021-09-20] v2.5.0 + +- add support for format tag (#72, askingcat) + +## [2021-09-18] v2.4.0 + +- add support for vendor extensions (#) + +## [2020-02-10] v2.3.0 + - Support for custom attribute "x-nullable" (#70) + ## v1.4.0 + v2.2.0 - Allow maps as top level types and support maps to slices (#63) diff --git a/vendor/github.com/emicklei/go-restful-openapi/LICENSE b/vendor/github.com/emicklei/go-restful-openapi/v2/LICENSE similarity index 100% rename from vendor/github.com/emicklei/go-restful-openapi/LICENSE rename to vendor/github.com/emicklei/go-restful-openapi/v2/LICENSE diff --git a/vendor/github.com/emicklei/go-restful-openapi/v2/Makefile b/vendor/github.com/emicklei/go-restful-openapi/v2/Makefile new file mode 100644 index 000000000..f2f20173d --- /dev/null +++ b/vendor/github.com/emicklei/go-restful-openapi/v2/Makefile @@ -0,0 +1,20 @@ +clean: + rm coverage.out + +test: + go test -cover -race -count=1 ./... + +coverage: + go test -coverprofile=coverage.out ./... + go tool cover -html=coverage.out + +# for local testing +lint: + docker run --rm -v $(PWD):$(PWD) -w $(PWD) golangci/golangci-lint:v1.33.0 golangci-lint run -v + +# for testing on CI/CD. we specify required linter version in the .travis.yml file +lint-ci: + golangci-lint run + +outdated: + go list -u -m -json all | docker run -i psampaz/go-mod-outdated -update -direct -ci \ No newline at end of file diff --git a/vendor/github.com/emicklei/go-restful-openapi/README.md b/vendor/github.com/emicklei/go-restful-openapi/v2/README.md similarity index 97% rename from vendor/github.com/emicklei/go-restful-openapi/README.md rename to vendor/github.com/emicklei/go-restful-openapi/v2/README.md index a5a081e17..52ecf4608 100644 --- a/vendor/github.com/emicklei/go-restful-openapi/README.md +++ b/vendor/github.com/emicklei/go-restful-openapi/v2/README.md @@ -27,7 +27,7 @@ See TestThatExtraTagsAreReadIntoModel for examples. ## Go modules Versions `v1` of this package require Go module version `v2` of the go-restful package. -To use version `v3` of the go-restful package, you need to import `v2 of this package, such as: +To use version `v3` of the go-restful package, you need to import `v2` of this package, such as: import ( restfulspec "github.com/emicklei/go-restful-openapi/v2" diff --git a/vendor/github.com/emicklei/go-restful-openapi/build_definitions.go b/vendor/github.com/emicklei/go-restful-openapi/v2/build_definitions.go similarity index 94% rename from vendor/github.com/emicklei/go-restful-openapi/build_definitions.go rename to vendor/github.com/emicklei/go-restful-openapi/v2/build_definitions.go index 95452554e..d46192007 100644 --- a/vendor/github.com/emicklei/go-restful-openapi/build_definitions.go +++ b/vendor/github.com/emicklei/go-restful-openapi/v2/build_definitions.go @@ -3,7 +3,7 @@ package restfulspec import ( "reflect" - restful "github.com/emicklei/go-restful" + restful "github.com/emicklei/go-restful/v3" "github.com/go-openapi/spec" ) diff --git a/vendor/github.com/emicklei/go-restful-openapi/build_path.go b/vendor/github.com/emicklei/go-restful-openapi/v2/build_path.go similarity index 54% rename from vendor/github.com/emicklei/go-restful-openapi/build_path.go rename to vendor/github.com/emicklei/go-restful-openapi/v2/build_path.go index 12b2432f8..9cc0779ba 100644 --- a/vendor/github.com/emicklei/go-restful-openapi/build_path.go +++ b/vendor/github.com/emicklei/go-restful-openapi/v2/build_path.go @@ -4,15 +4,25 @@ import ( "net/http" "reflect" "regexp" + "sort" "strconv" "strings" - restful "github.com/emicklei/go-restful" "github.com/go-openapi/spec" + + "github.com/emicklei/go-restful/v3" ) -// KeyOpenAPITags is a Metadata key for a restful Route -const KeyOpenAPITags = "openapi.tags" +const ( + // KeyOpenAPITags is a Metadata key for a restful Route + KeyOpenAPITags = "openapi.tags" + + // ExtensionPrefix is the only prefix accepted for VendorExtensible extension keys + ExtensionPrefix = "x-" + + arrayType = "array" + definitionRoot = "#/definitions/" +) func buildPaths(ws *restful.WebService, cfg Config) spec.Paths { p := spec.Paths{Paths: map[string]spec.PathItem{}} @@ -28,8 +38,8 @@ func buildPaths(ws *restful.WebService, cfg Config) spec.Paths { } // sanitizePath removes regex expressions from named path params, -// since openapi only supports setting the pattern as a a property named "pattern". -// Expressions like "/api/v1/{name:[a-z]/" are converted to "/api/v1/{name}/". +// since openapi only supports setting the pattern as a property named "pattern". +// Expressions like "/api/v1/{name:[a-z]}/" are converted to "/api/v1/{name}/". // The second return value is a map which contains the mapping from the path parameter // name to the extracted pattern func sanitizePath(restfulPath string) (string, map[string]string) { @@ -41,10 +51,16 @@ func sanitizePath(restfulPath string) (string, map[string]string) { } if strings.HasPrefix(fragment, "{") && strings.Contains(fragment, ":") { split := strings.Split(fragment, ":") - fragment = split[0][1:] - pattern := split[1][:len(split[1])-1] - patterns[fragment] = pattern - fragment = "{" + fragment + "}" + // skip google custom method like `resource/{resource-id}:customVerb` + if !strings.Contains(split[0], "}") { + fragment = split[0][1:] + pattern := split[1][:len(split[1])-1] + if pattern == "*" { // special case + pattern = ".*" + } + patterns[fragment] = pattern + fragment = "{" + fragment + "}" + } } openapiPath += "/" + fragment } @@ -54,19 +70,19 @@ func sanitizePath(restfulPath string) (string, map[string]string) { func buildPathItem(ws *restful.WebService, r restful.Route, existingPathItem spec.PathItem, patterns map[string]string, cfg Config) spec.PathItem { op := buildOperation(ws, r, patterns, cfg) switch r.Method { - case "GET": + case http.MethodGet: existingPathItem.Get = op - case "POST": + case http.MethodPost: existingPathItem.Post = op - case "PUT": + case http.MethodPut: existingPathItem.Put = op - case "DELETE": + case http.MethodDelete: existingPathItem.Delete = op - case "PATCH": + case http.MethodPatch: existingPathItem.Patch = op - case "OPTIONS": + case http.MethodOptions: existingPathItem.Options = op - case "HEAD": + case http.MethodHead: existingPathItem.Head = op } return existingPathItem @@ -86,24 +102,29 @@ func buildOperation(ws *restful.WebService, r restful.Route, patterns map[string } } } + + extractVendorExtensions(&o.VendorExtensible, r.ExtensionProperties) + // collect any path parameters for _, param := range ws.PathParameters() { - o.Parameters = append(o.Parameters, buildParameter(r, param, patterns[param.Data().Name], cfg)) + p := buildParameter(r, param, patterns[param.Data().Name], cfg) + o.Parameters = append(o.Parameters, p) } // route specific params - for _, each := range r.ParameterDocs { - o.Parameters = append(o.Parameters, buildParameter(r, each, patterns[each.Data().Name], cfg)) + for _, param := range r.ParameterDocs { + p := buildParameter(r, param, patterns[param.Data().Name], cfg) + o.Parameters = append(o.Parameters, p) } o.Responses = new(spec.Responses) props := &o.Responses.ResponsesProps - props.StatusCodeResponses = map[int]spec.Response{} + props.StatusCodeResponses = make(map[int]spec.Response, len(r.ResponseErrors)) for k, v := range r.ResponseErrors { r := buildResponse(v, cfg) props.StatusCodeResponses[k] = r } if r.DefaultResponse != nil { - r := buildResponse(*r.DefaultResponse, cfg) - o.Responses.Default = &r + rsp := buildResponse(*r.DefaultResponse, cfg) + o.Responses.Default = &rsp } if len(o.Responses.StatusCodeResponses) == 0 { o.Responses.StatusCodeResponses[200] = spec.Response{ResponseProps: spec.ResponseProps{Description: http.StatusText(http.StatusOK)}} @@ -126,23 +147,77 @@ func stringAutoType(ambiguous string) interface{} { return ambiguous } +func extractVendorExtensions(extensible *spec.VendorExtensible, extensions restful.ExtensionProperties) { + if len(extensions.Extensions) > 0 { + for key := range extensions.Extensions { + if strings.HasPrefix(key, ExtensionPrefix) { + extensible.AddExtension(key, extensions.Extensions[key]) + } + } + } +} + func buildParameter(r restful.Route, restfulParam *restful.Parameter, pattern string, cfg Config) spec.Parameter { p := spec.Parameter{} param := restfulParam.Data() p.In = asParamType(param.Kind) - p.Description = param.Description - p.Name = param.Name - p.Required = param.Required - if len(param.AllowableValues) > 0 { - p.Enum = make([]interface{}, 0, len(param.AllowableValues)) - for key := range param.AllowableValues { - p.Enum = append(p.Enum, key) + if param.AllowMultiple { + // If the param is an array apply the validations to the items in it + p.Type = arrayType + p.Items = spec.NewItems() + p.Items.Type = param.DataType + p.Items.Pattern = param.Pattern + p.Items.MinLength = param.MinLength + p.Items.MaxLength = param.MaxLength + p.CollectionFormat = param.CollectionFormat + p.MinItems = param.MinItems + p.MaxItems = param.MaxItems + p.UniqueItems = param.UniqueItems + } else { + // Otherwise, for non-arrays, apply the validations directly to the param + p.Type = param.DataType + p.MinLength = param.MinLength + p.MaxLength = param.MaxLength + p.Minimum = param.Minimum + p.Maximum = param.Maximum + } + + // Prefer PossibleValues over deprecated AllowableValues + if numPossible := len(param.PossibleValues); numPossible > 0 { + // init Enum to our known size and populate it + p.Enum = make([]interface{}, 0, numPossible) + for _, value := range param.PossibleValues { + p.Enum = append(p.Enum, value) + } + } else { + if numAllowable := len(param.AllowableValues); numAllowable > 0 { + // If allowable values are defined, set the enum array to the sorted values + allowableSortedKeys := make([]string, 0, numAllowable) + for k := range param.AllowableValues { + allowableSortedKeys = append(allowableSortedKeys, k) + } + + // sort away + sort.Strings(allowableSortedKeys) + + // init Enum to our known size and populate it + p.Enum = make([]interface{}, 0, numAllowable) + for _, key := range allowableSortedKeys { + p.Enum = append(p.Enum, param.AllowableValues[key]) + } } } + p.Description = param.Description + p.Name = param.Name + p.Required = param.Required + p.AllowEmptyValue = param.AllowEmptyValue + if param.Kind == restful.PathParameterKind { p.Pattern = pattern + } else if !param.AllowMultiple { + p.Pattern = param.Pattern } st := reflect.TypeOf(r.ReadSample) if param.Kind == restful.BodyParameterKind && r.ReadSample != nil && param.DataType == st.String() { @@ -150,7 +225,7 @@ func buildParameter(r restful.Route, restfulParam *restful.Parameter, pattern st p.SimpleSchema = spec.SimpleSchema{} if st.Kind() == reflect.Array || st.Kind() == reflect.Slice { dataTypeName := keyFrom(st.Elem(), cfg) - p.Schema.Type = []string{"array"} + p.Schema.Type = []string{arrayType} p.Schema.Items = &spec.SchemaOrArray{ Schema: &spec.Schema{}, } @@ -159,16 +234,16 @@ func buildParameter(r restful.Route, restfulParam *restful.Parameter, pattern st mapped := jsonSchemaType(dataTypeName) p.Schema.Items.Schema.Type = []string{mapped} } else { - p.Schema.Items.Schema.Ref = spec.MustCreateRef("#/definitions/" + dataTypeName) + p.Schema.Items.Schema.Ref = spec.MustCreateRef(definitionRoot + dataTypeName) } } else { dataTypeName := keyFrom(st, cfg) - p.Schema.Ref = spec.MustCreateRef("#/definitions/" + dataTypeName) + p.Schema.Ref = spec.MustCreateRef(definitionRoot + dataTypeName) } } else { if param.AllowMultiple { - p.Type = "array" + p.Type = arrayType p.Items = spec.NewItems() p.Items.Type = param.DataType p.CollectionFormat = param.CollectionFormat @@ -179,6 +254,8 @@ func buildParameter(r restful.Route, restfulParam *restful.Parameter, pattern st p.Format = param.DataFormat } + extractVendorExtensions(&p.VendorExtensible, param.ExtensionProperties) + return p } @@ -194,7 +271,7 @@ func buildResponse(e restful.ResponseError, cfg Config) (r spec.Response) { r.Schema = new(spec.Schema) if st.Kind() == reflect.Array || st.Kind() == reflect.Slice { modelName := keyFrom(st.Elem(), cfg) - r.Schema.Type = []string{"array"} + r.Schema.Type = []string{arrayType} r.Schema.Items = &spec.SchemaOrArray{ Schema: &spec.Schema{}, } @@ -203,7 +280,7 @@ func buildResponse(e restful.ResponseError, cfg Config) (r spec.Response) { mapped := jsonSchemaType(modelName) r.Schema.Items.Schema.Type = []string{mapped} } else { - r.Schema.Items.Schema.Ref = spec.MustCreateRef("#/definitions/" + modelName) + r.Schema.Items.Schema.Ref = spec.MustCreateRef(definitionRoot + modelName) } } else { modelName := keyFrom(st, cfg) @@ -213,13 +290,53 @@ func buildResponse(e restful.ResponseError, cfg Config) (r spec.Response) { r.Schema.AddType(modelName, "") } else { modelName := keyFrom(st, cfg) - r.Schema.Ref = spec.MustCreateRef("#/definitions/" + modelName) + r.Schema.Ref = spec.MustCreateRef(definitionRoot + modelName) } } } + + if len(e.Headers) > 0 { + r.Headers = make(map[string]spec.Header, len(e.Headers)) + for k, v := range e.Headers { + r.Headers[k] = buildHeader(v) + } + } + + extractVendorExtensions(&r.VendorExtensible, e.ExtensionProperties) return r } +// buildHeader builds a specification header structure from restful.Header +func buildHeader(header restful.Header) spec.Header { + responseHeader := spec.Header{} + responseHeader.Type = header.Type + responseHeader.Description = header.Description + responseHeader.Format = header.Format + responseHeader.Default = header.Default + + // If type is "array" items field is required + if header.Type == arrayType { + responseHeader.CollectionFormat = header.CollectionFormat + responseHeader.Items = buildHeadersItems(header.Items) + } + + return responseHeader +} + +// buildHeadersItems builds +func buildHeadersItems(items *restful.Items) *spec.Items { + responseItems := spec.NewItems() + responseItems.Format = items.Format + responseItems.Type = items.Type + responseItems.Default = items.Default + responseItems.CollectionFormat = items.CollectionFormat + if items.Items != nil { + responseItems.Items = buildHeadersItems(items.Items) + } + + return responseItems +} + // stripTags takes a snippet of HTML and returns only the text content. // For example, `<Hi!>
` -> `<Hi!> `. func stripTags(html string) string { @@ -248,11 +365,11 @@ func jsonSchemaType(modelName string) string { "int32": "integer", "int64": "integer", - "byte": "integer", - "float64": "number", - "float32": "number", - "bool": "boolean", - "time.Time": "string", + "byte": "integer", + "float64": "number", + "float32": "number", + "bool": "boolean", + "time.Time": "string", "time.Duration": "integer", } mapped, ok := schemaMap[modelName] diff --git a/vendor/github.com/emicklei/go-restful-openapi/config.go b/vendor/github.com/emicklei/go-restful-openapi/v2/config.go similarity index 60% rename from vendor/github.com/emicklei/go-restful-openapi/config.go rename to vendor/github.com/emicklei/go-restful-openapi/v2/config.go index 354a7c960..ba2f01099 100644 --- a/vendor/github.com/emicklei/go-restful-openapi/config.go +++ b/vendor/github.com/emicklei/go-restful-openapi/v2/config.go @@ -3,7 +3,7 @@ package restfulspec import ( "reflect" - restful "github.com/emicklei/go-restful" + "github.com/emicklei/go-restful/v3" "github.com/go-openapi/spec" ) @@ -20,13 +20,29 @@ type MapModelTypeNameFunc func(t reflect.Type) (string, bool) // before serving it. To use it set the PostBuildSwaggerObjectHandler in the config. type PostBuildSwaggerObjectFunc func(s *spec.Swagger) +// DefinitionNameHandlerFunc generate name by this handler for definition without json tag. +// example: (for more, see file definition_name_test.go) +// field definition_name +// Name `json:"name"` -> name +// Name -> Name +// +// there are some example provided for use +// DefaultNameHandler GoRestfulDefinition -> GoRestfulDefinition (not changed) +// LowerSnakeCasedNameHandler GoRestfulDefinition -> go_restful_definition +// LowerCamelCasedNameHandler GoRestfulDefinition -> goRestfulDefinition +// GoLowerCamelCasedNameHandler HTTPRestfulDefinition -> httpRestfulDefinition +// +type DefinitionNameHandlerFunc func(string) string + // Config holds service api metadata. type Config struct { // [optional] If set then set this field with the generated Swagger Object Host string + // [optional] If set then set this field with the generated Swagger Object + Schemes []string // WebServicesURL is a DEPRECATED field; it never had any effect in this package. WebServicesURL string - // APIPath is the path where the JSON api is avaiable , e.g. /apidocs.json + // APIPath is the path where the JSON api is available, e.g. /apidocs.json APIPath string // api listing is constructed from this list of restful WebServices. WebServices []*restful.WebService @@ -40,4 +56,7 @@ type Config struct { ModelTypeNameHandler MapModelTypeNameFunc // [optional] If set then call this function with the generated Swagger Object PostBuildSwaggerObjectHandler PostBuildSwaggerObjectFunc + // [optional] If set then call handler's function for to generate name by this handler for definition without json tag, + // you can use you DefinitionNameHandler, also, there are four DefinitionNameHandler provided, see definition_name.go + DefinitionNameHandler DefinitionNameHandlerFunc } diff --git a/vendor/github.com/emicklei/go-restful-openapi/definition_builder.go b/vendor/github.com/emicklei/go-restful-openapi/v2/definition_builder.go similarity index 94% rename from vendor/github.com/emicklei/go-restful-openapi/definition_builder.go rename to vendor/github.com/emicklei/go-restful-openapi/v2/definition_builder.go index 48ff7e505..eeb9f1341 100644 --- a/vendor/github.com/emicklei/go-restful-openapi/definition_builder.go +++ b/vendor/github.com/emicklei/go-restful-openapi/v2/definition_builder.go @@ -18,6 +18,10 @@ type Documented interface { SwaggerDoc() map[string]string } +type PostBuildSwaggerSchema interface { + PostBuildSwaggerSchemaHandler(sm *spec.Schema) +} + // Check if this structure has a method with signature func () SwaggerDoc() map[string]string // If it exists, retrieve the documentation and overwrite all struct tag descriptions func getDocFromMethodSwaggerDoc2(model reflect.Type) map[string]string { @@ -36,10 +40,12 @@ func (b definitionBuilder) addModelFrom(sample interface{}) { func (b definitionBuilder) addModel(st reflect.Type, nameOverride string) *spec.Schema { // Turn pointers into simpler types so further checks are // correct. + isArray := false if st.Kind() == reflect.Ptr { st = st.Elem() } if b.isSliceOrArrayType(st.Kind()) { + isArray = true st = st.Elem() } @@ -47,9 +53,11 @@ func (b definitionBuilder) addModel(st reflect.Type, nameOverride string) *spec. if nameOverride != "" { modelName = nameOverride } - // no models needed for primitive types + // no models needed for primitive types unless it has alias if b.isPrimitiveType(modelName, st.Kind()) { - return nil + if nameOverride == "" { + return nil + } } // golang encoding/json packages says array and slice values encode as // JSON arrays, except that []byte encodes as a base64-encoded string. @@ -69,6 +77,15 @@ func (b definitionBuilder) addModel(st reflect.Type, nameOverride string) *spec. }, } + // fixes issue 77 but feels like a workaround. + if b.isPrimitiveType(modelName, st.Kind()) { + if isArray { + sm.Type = []string{"array"} + sm.Items = &spec.SchemaOrArray{Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{Type: []string{jsonSchemaType(st.Kind().String())}}}} + } + } + // reference the model before further initializing (enables recursive structs) b.Definitions[modelName] = sm @@ -118,6 +135,11 @@ func (b definitionBuilder) addModel(st reflect.Type, nameOverride string) *spec. // See https://github.com/go-openapi/spec/issues/23 for more context sm.ID = "" + // Call handler to update sch + if handler, ok := reflect.New(st).Elem().Interface().(PostBuildSwaggerSchema); ok { + handler.PostBuildSwaggerSchemaHandler(&sm) + } + // update model builder with completed model b.Definitions[modelName] = sm @@ -246,7 +268,7 @@ func (b definitionBuilder) buildStructTypeProperty(field reflect.StructField, js if field.Name == fieldType.Name() && field.Anonymous && !hasNamedJSONTag(field) { // embedded struct - sub := definitionBuilder{make(spec.Definitions), b.Config} + sub := definitionBuilder{b.Definitions, b.Config} sub.addModel(fieldType, "") subKey := keyFrom(fieldType, b.Config) // merge properties from sub @@ -301,6 +323,7 @@ func (b definitionBuilder) buildArrayTypeProperty(field reflect.StructField, jso if isPrimitive { mapped := b.jsonSchemaType(elemTypeName, fieldType.Elem().Kind()) prop.Items.Schema.Type = []string{mapped} + prop.Items.Schema.Format = b.jsonSchemaFormat(elemTypeName, fieldType.Elem().Kind()) } else { prop.Items.Schema.Ref = spec.MustCreateRef("#/definitions/" + elemTypeName) } @@ -485,7 +508,11 @@ func (b definitionBuilder) jsonNameOfField(field reflect.StructField) string { return s[0] } } - return field.Name + + if b.Config.DefinitionNameHandler == nil { + b.Config.DefinitionNameHandler = DefaultNameHandler + } + return b.Config.DefinitionNameHandler(field.Name) } // see also http://json-schema.org/latest/json-schema-core.html#anchor8 @@ -526,8 +553,8 @@ func (b definitionBuilder) jsonSchemaFormat(modelName string, modelKind reflect. schemaMap := map[string]string{ "time.Time": "date-time", "*time.Time": "date-time", - "time.Duration": "integer", - "*time.Duration": "integer", + "time.Duration": "int64", + "*time.Duration": "int64", "json.Number": "double", "*json.Number": "double", } diff --git a/vendor/github.com/emicklei/go-restful-openapi/v2/definition_name.go b/vendor/github.com/emicklei/go-restful-openapi/v2/definition_name.go new file mode 100644 index 000000000..356e55838 --- /dev/null +++ b/vendor/github.com/emicklei/go-restful-openapi/v2/definition_name.go @@ -0,0 +1,105 @@ +package restfulspec + +import "strings" + +// DefaultNameHandler GoRestfulDefinition -> GoRestfulDefinition (not changed) +func DefaultNameHandler(name string) string { + return name +} + +// LowerSnakeCasedNameHandler GoRestfulDefinition -> go_restful_definition +func LowerSnakeCasedNameHandler(name string) string { + definitionName := make([]byte, 0, len(name)+1) + for i := 0; i < len(name); i++ { + c := name[i] + if isUpper(c) { + if i > 0 { + definitionName = append(definitionName, '_') + } + c += 'a' - 'A' + } + definitionName = append(definitionName, c) + } + + return string(definitionName) +} + +// LowerCamelCasedNameHandler GoRestfulDefinition -> goRestfulDefinition +func LowerCamelCasedNameHandler(name string) string { + definitionName := make([]byte, 0, len(name)+1) + for i := 0; i < len(name); i++ { + c := name[i] + if isUpper(c) && i == 0 { + c += 'a' - 'A' + } + definitionName = append(definitionName, c) + } + + return string(definitionName) +} + +// GoLowerCamelCasedNameHandler HTTPRestfulDefinition -> httpRestfulDefinition +func GoLowerCamelCasedNameHandler(name string) string { + var i = 0 + // for continuous Upper letters, check whether is it a common Initialisms + for ; i < len(name) && isUpper(name[i]); i++ { + } + if len(name) != i && i > 1 { + i-- // for continuous Upper letters, the last Upper is should not be check, eg: S for HTTPStatus + } + for ; i > 1; i-- { + if _, ok := commonInitialisms[name[:i]]; ok { + break + } + } + + return strings.ToLower(name[:i]) + name[i:] +} + +// commonInitialisms is a set of common initialisms. (from https://github.com/golang/lint/blob/master/lint.go) +// Only add entries that are highly unlikely to be non-initialisms. +// For instance, "ID" is fine (Freudian code is rare), but "AND" is not. +var commonInitialisms = map[string]bool{ + "ACL": true, + "API": true, + "ASCII": true, + "CPU": true, + "CSS": true, + "DNS": true, + "EOF": true, + "GUID": true, + "HTML": true, + "HTTP": true, + "HTTPS": true, + "ID": true, + "IP": true, + "JSON": true, + "LHS": true, + "QPS": true, + "RAM": true, + "RHS": true, + "RPC": true, + "SLA": true, + "SMTP": true, + "SQL": true, + "SSH": true, + "TCP": true, + "TLS": true, + "TTL": true, + "UDP": true, + "UI": true, + "UID": true, + "UUID": true, + "URI": true, + "URL": true, + "UTF8": true, + "VM": true, + "XML": true, + "XMPP": true, + "XSRF": true, + "XSS": true, +} + +func isUpper(r uint8) bool { + return 'A' <= r && r <= 'Z' +} diff --git a/vendor/github.com/emicklei/go-restful-openapi/lookup.go b/vendor/github.com/emicklei/go-restful-openapi/v2/lookup.go similarity index 88% rename from vendor/github.com/emicklei/go-restful-openapi/lookup.go rename to vendor/github.com/emicklei/go-restful-openapi/v2/lookup.go index 27407107a..80defc1a3 100644 --- a/vendor/github.com/emicklei/go-restful-openapi/lookup.go +++ b/vendor/github.com/emicklei/go-restful-openapi/v2/lookup.go @@ -1,6 +1,6 @@ package restfulspec -import restful "github.com/emicklei/go-restful" +import restful "github.com/emicklei/go-restful/v3" func asParamType(kind int) string { switch { diff --git a/vendor/github.com/emicklei/go-restful-openapi/property_ext.go b/vendor/github.com/emicklei/go-restful-openapi/v2/property_ext.go similarity index 71% rename from vendor/github.com/emicklei/go-restful-openapi/property_ext.go rename to vendor/github.com/emicklei/go-restful-openapi/v2/property_ext.go index eb91208bc..bce82e545 100644 --- a/vendor/github.com/emicklei/go-restful-openapi/property_ext.go +++ b/vendor/github.com/emicklei/go-restful-openapi/v2/property_ext.go @@ -8,6 +8,12 @@ import ( "github.com/go-openapi/spec" ) +func initPropExtensions(ext *spec.Extensions) { + if *ext == nil { + *ext = make(spec.Extensions, 0) + } +} + func setDescription(prop *spec.Schema, field reflect.StructField) { if tag := field.Tag.Get("description"); tag != "" { prop.Description = tag @@ -20,9 +26,27 @@ func setDefaultValue(prop *spec.Schema, field reflect.StructField) { } } +func setIsNullableValue(prop *spec.Schema, field reflect.StructField) { + if tag := field.Tag.Get("x-nullable"); tag != "" { + initPropExtensions(&prop.Extensions) + + value, err := strconv.ParseBool(tag) + + prop.Extensions["x-nullable"] = value && err == nil + } +} + +func setGoNameValue(prop *spec.Schema, field reflect.StructField) { + const tagName = "x-go-name" + if tag := field.Tag.Get(tagName); tag != "" { + initPropExtensions(&prop.Extensions) + prop.Extensions[tagName] = tag + } +} + func setEnumValues(prop *spec.Schema, field reflect.StructField) { // We use | to separate the enum values. This value is chosen - // since its unlikely to be useful in actual enumeration values. + // since it's unlikely to be useful in actual enumeration values. if tag := field.Tag.Get("enum"); tag != "" { enums := []interface{}{} for _, s := range strings.Split(tag, "|") { @@ -32,6 +56,13 @@ func setEnumValues(prop *spec.Schema, field reflect.StructField) { } } +func setFormat(prop *spec.Schema, field reflect.StructField) { + if tag := field.Tag.Get("format"); tag != "" { + prop.Format = tag + } + +} + func setMaximum(prop *spec.Schema, field reflect.StructField) { if tag := field.Tag.Get("maximum"); tag != "" { value, err := strconv.ParseFloat(tag, 64) @@ -56,7 +87,7 @@ func setType(prop *spec.Schema, field reflect.StructField) { // intended to emulate slice/array behaviour. // // If type is intended to be a slice/array then add the - // overriden type to the array item instead of the main property + // overridden type to the array item instead of the main property if len(tag) > 2 && tag[0:2] == "[]" { pType := "array" prop.Type = []string{pType} @@ -96,9 +127,12 @@ func setPropertyMetadata(prop *spec.Schema, field reflect.StructField) { setDescription(prop, field) setDefaultValue(prop, field) setEnumValues(prop, field) + setFormat(prop, field) setMinimum(prop, field) setMaximum(prop, field) setUniqueItems(prop, field) setType(prop, field) setReadOnly(prop, field) + setIsNullableValue(prop, field) + setGoNameValue(prop, field) } diff --git a/vendor/github.com/emicklei/go-restful-openapi/spec_resource.go b/vendor/github.com/emicklei/go-restful-openapi/v2/spec_resource.go similarity index 96% rename from vendor/github.com/emicklei/go-restful-openapi/spec_resource.go rename to vendor/github.com/emicklei/go-restful-openapi/v2/spec_resource.go index b673e83fe..3e6e151a3 100644 --- a/vendor/github.com/emicklei/go-restful-openapi/spec_resource.go +++ b/vendor/github.com/emicklei/go-restful-openapi/v2/spec_resource.go @@ -1,7 +1,7 @@ package restfulspec import ( - restful "github.com/emicklei/go-restful" + restful "github.com/emicklei/go-restful/v3" "github.com/go-openapi/spec" ) @@ -46,6 +46,7 @@ func BuildSwagger(config Config) *spec.Swagger { swagger := &spec.Swagger{ SwaggerProps: spec.SwaggerProps{ Host: config.Host, + Schemes: config.Schemes, Swagger: "2.0", Paths: paths, Definitions: definitions, diff --git a/vendor/github.com/emicklei/go-restful/.gitignore b/vendor/github.com/emicklei/go-restful/.gitignore deleted file mode 100644 index 446be09b4..000000000 --- a/vendor/github.com/emicklei/go-restful/.gitignore +++ /dev/null @@ -1,71 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe - -restful.html - -*.out - -tmp.prof - -go-restful.test - -examples/restful-basic-authentication - -examples/restful-encoding-filter - -examples/restful-filters - -examples/restful-hello-world - -examples/restful-resource-functions - -examples/restful-serve-static - -examples/restful-user-service - -*.DS_Store -examples/restful-user-resource - -examples/restful-multi-containers - -examples/restful-form-handling - -examples/restful-CORS-filter - -examples/restful-options-filter - -examples/restful-curly-router - -examples/restful-cpuprofiler-service - -examples/restful-pre-post-filters - -curly.prof - -examples/restful-NCSA-logging - -examples/restful-html-template - -s.html -restful-path-tail -.idea diff --git a/vendor/github.com/emicklei/go-restful/.travis.yml b/vendor/github.com/emicklei/go-restful/.travis.yml deleted file mode 100644 index 3a0bf5ff1..000000000 --- a/vendor/github.com/emicklei/go-restful/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: go - -go: - - 1.x - -before_install: - - go test -v - -script: - - go test -race -coverprofile=coverage.txt -covermode=atomic - -after_success: - - bash <(curl -s https://codecov.io/bash) \ No newline at end of file diff --git a/vendor/github.com/emicklei/go-restful/CHANGES.md b/vendor/github.com/emicklei/go-restful/CHANGES.md deleted file mode 100644 index 3a5299474..000000000 --- a/vendor/github.com/emicklei/go-restful/CHANGES.md +++ /dev/null @@ -1,318 +0,0 @@ -# Change history of go-restful (v2 only) - -## v2.16.0 - 2022-07-11 - -- 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 - -- Added check on writer to prevent compression of response twice. #447 - -## 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 - -- 405 Method Not Allowed must have Allow header (#436) -- add field allowedMethodsWithoutContentType (#424) - -## v2.12.0 - -- support describing response headers (#426) -- fix openapi examples (#425) -- merge v3 fix (#422) - -## v2.11.1 - -- fix WriteError return value (#415) - -## v2.11.0 - -- allow prefix and suffix in path variable expression (#414) - -## v2.9.6 - -- support google custome verb (#413) - -## v2.9.5 - -- fix panic in Response.WriteError if err == nil - -## v2.9.4 - -- fix issue #400 , parsing mime type quality -- Route Builder added option for contentEncodingEnabled (#398) - -## v2.9.3 - -- Avoid return of 415 Unsupported Media Type when request body is empty (#396) - -## v2.9.2 - -- Reduce allocations in per-request methods to improve performance (#395) - -## v2.9.1 - -- Fix issue with default responses and invalid status code 0. (#393) - -## v2.9.0 - -- add per Route content encoding setting (overrides container setting) - -## v2.8.0 - -- add Request.QueryParameters() -- add json-iterator (via build tag) -- disable vgo module (until log is moved) - -## v2.7.1 - -- add vgo module - -## v2.6.1 - -- add JSONNewDecoderFunc to allow custom JSON Decoder usage (go 1.10+) - -## v2.6.0 - -- Make JSR 311 routing and path param processing consistent -- Adding description to RouteBuilder.Reads() -- Update example for Swagger12 and OpenAPI - -## 2017-09-13 - -- added route condition functions using `.If(func)` in route building. - -## 2017-02-16 - -- solved issue #304, make operation names unique - -## 2017-01-30 - - [IMPORTANT] For swagger users, change your import statement to: - swagger "github.com/emicklei/go-restful-swagger12" - -- moved swagger 1.2 code to go-restful-swagger12 -- created TAG 2.0.0 - -## 2017-01-27 - -- remove defer request body close -- expose Dispatch for testing filters and Routefunctions -- swagger response model cannot be array -- created TAG 1.0.0 - -## 2016-12-22 - -- (API change) Remove code related to caching request content. Removes SetCacheReadEntity(doCache bool) - -## 2016-11-26 - -- Default change! now use CurlyRouter (was RouterJSR311) -- Default change! no more caching of request content -- Default change! do not recover from panics - -## 2016-09-22 - -- fix the DefaultRequestContentType feature - -## 2016-02-14 - -- take the qualify factor of the Accept header mediatype into account when deciding the contentype of the response -- add constructors for custom entity accessors for xml and json - -## 2015-09-27 - -- rename new WriteStatusAnd... to WriteHeaderAnd... for consistency - -## 2015-09-25 - -- fixed problem with changing Header after WriteHeader (issue 235) - -## 2015-09-14 - -- changed behavior of WriteHeader (immediate write) and WriteEntity (no status write) -- added support for custom EntityReaderWriters. - -## 2015-08-06 - -- add support for reading entities from compressed request content -- use sync.Pool for compressors of http response and request body -- add Description to Parameter for documentation in Swagger UI - -## 2015-03-20 - -- add configurable logging - -## 2015-03-18 - -- if not specified, the Operation is derived from the Route function - -## 2015-03-17 - -- expose Parameter creation functions -- make trace logger an interface -- fix OPTIONSFilter -- customize rendering of ServiceError -- JSR311 router now handles wildcards -- add Notes to Route - -## 2014-11-27 - -- (api add) PrettyPrint per response. (as proposed in #167) - -## 2014-11-12 - -- (api add) ApiVersion(.) for documentation in Swagger UI - -## 2014-11-10 - -- (api change) struct fields tagged with "description" show up in Swagger UI - -## 2014-10-31 - -- (api change) ReturnsError -> Returns -- (api add) RouteBuilder.Do(aBuilder) for DRY use of RouteBuilder -- fix swagger nested structs -- sort Swagger response messages by code - -## 2014-10-23 - -- (api add) ReturnsError allows you to document Http codes in swagger -- fixed problem with greedy CurlyRouter -- (api add) Access-Control-Max-Age in CORS -- add tracing functionality (injectable) for debugging purposes -- support JSON parse 64bit int -- fix empty parameters for swagger -- WebServicesUrl is now optional for swagger -- fixed duplicate AccessControlAllowOrigin in CORS -- (api change) expose ServeMux in container -- (api add) added AllowedDomains in CORS -- (api add) ParameterNamed for detailed documentation - -## 2014-04-16 - -- (api add) expose constructor of Request for testing. - -## 2014-06-27 - -- (api add) ParameterNamed gives access to a Parameter definition and its data (for further specification). -- (api add) SetCacheReadEntity allow scontrol over whether or not the request body is being cached (default true for compatibility reasons). - -## 2014-07-03 - -- (api add) CORS can be configured with a list of allowed domains - -## 2014-03-12 - -- (api add) Route path parameters can use wildcard or regular expressions. (requires CurlyRouter) - -## 2014-02-26 - -- (api add) Request now provides information about the matched Route, see method SelectedRoutePath - -## 2014-02-17 - -- (api change) renamed parameter constants (go-lint checks) - -## 2014-01-10 - -- (api add) support for CloseNotify, see http://golang.org/pkg/net/http/#CloseNotifier - -## 2014-01-07 - -- (api change) Write* methods in Response now return the error or nil. -- added example of serving HTML from a Go template. -- fixed comparing Allowed headers in CORS (is now case-insensitive) - -## 2013-11-13 - -- (api add) Response knows how many bytes are written to the response body. - -## 2013-10-29 - -- (api add) RecoverHandler(handler RecoverHandleFunction) to change how panic recovery is handled. Default behavior is to log and return a stacktrace. This may be a security issue as it exposes sourcecode information. - -## 2013-10-04 - -- (api add) Response knows what HTTP status has been written -- (api add) Request can have attributes (map of string->interface, also called request-scoped variables - -## 2013-09-12 - -- (api change) Router interface simplified -- Implemented CurlyRouter, a Router that does not use|allow regular expressions in paths - -## 2013-08-05 - - add OPTIONS support - - add CORS support - -## 2013-08-27 - -- fixed some reported issues (see github) -- (api change) deprecated use of WriteError; use WriteErrorString instead - -## 2014-04-15 - -- (fix) v1.0.1 tag: fix Issue 111: WriteErrorString - -## 2013-08-08 - -- (api add) Added implementation Container: a WebServices collection with its own http.ServeMux allowing multiple endpoints per program. Existing uses of go-restful will register their services to the DefaultContainer. -- (api add) the swagger package has be extended to have a UI per container. -- if panic is detected then a small stack trace is printed (thanks to runner-mei) -- (api add) WriteErrorString to Response - -Important API changes: - -- (api remove) package variable DoNotRecover no longer works ; use restful.DefaultContainer.DoNotRecover(true) instead. -- (api remove) package variable EnableContentEncoding no longer works ; use restful.DefaultContainer.EnableContentEncoding(true) instead. - - -## 2013-07-06 - -- (api add) Added support for response encoding (gzip and deflate(zlib)). This feature is disabled on default (for backwards compatibility). Use restful.EnableContentEncoding = true in your initialization to enable this feature. - -## 2013-06-19 - -- (improve) DoNotRecover option, moved request body closer, improved ReadEntity - -## 2013-06-03 - -- (api change) removed Dispatcher interface, hide PathExpression -- changed receiver names of type functions to be more idiomatic Go - -## 2013-06-02 - -- (optimize) Cache the RegExp compilation of Paths. - -## 2013-05-22 - -- (api add) Added support for request/response filter functions - -## 2013-05-18 - - -- (api add) Added feature to change the default Http Request Dispatch function (travis cline) -- (api change) Moved Swagger Webservice to swagger package (see example restful-user) - -## [2012-11-14 .. 2013-05-18> - -- See https://github.com/emicklei/go-restful/commits - -## 2012-11-14 - -- Initial commit - - diff --git a/vendor/github.com/emicklei/go-restful/LICENSE b/vendor/github.com/emicklei/go-restful/LICENSE deleted file mode 100644 index ece7ec61e..000000000 --- a/vendor/github.com/emicklei/go-restful/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2012,2013 Ernest Micklei - -MIT License - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/vendor/github.com/emicklei/go-restful/Makefile b/vendor/github.com/emicklei/go-restful/Makefile deleted file mode 100644 index 3a824ac3d..000000000 --- a/vendor/github.com/emicklei/go-restful/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -all: test - -test: - go vet . - go test -cover -v . \ No newline at end of file diff --git a/vendor/github.com/emicklei/go-restful/README.md b/vendor/github.com/emicklei/go-restful/README.md deleted file mode 100644 index e5878a668..000000000 --- a/vendor/github.com/emicklei/go-restful/README.md +++ /dev/null @@ -1,111 +0,0 @@ -go-restful -========== -package for building REST-style Web Services using Google Go - -[![Build Status](https://travis-ci.org/emicklei/go-restful.png)](https://travis-ci.org/emicklei/go-restful) -[![Go Report Card](https://goreportcard.com/badge/github.com/emicklei/go-restful)](https://goreportcard.com/report/github.com/emicklei/go-restful) -[![GoDoc](https://godoc.org/github.com/emicklei/go-restful?status.svg)](https://pkg.go.dev/github.com/emicklei/go-restful) -[![codecov](https://codecov.io/gh/emicklei/go-restful/branch/master/graph/badge.svg)](https://codecov.io/gh/emicklei/go-restful) - -- [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: - -- 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 - -#### 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" -) -``` - -#### 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 -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") - ... -} -``` - -[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 -- Configurable router: - - (default) Fast routing algorithm that allows static elements, [google custom method](https://cloud.google.com/apis/design/custom_methods), regular expressions and dynamic parameters in the URL path (e.g. /resource/name:customVerb, /meetings/{id} or /static/{subpath:*}) - - Routing algorithm after [JSR311](http://jsr311.java.net/nonav/releases/1.1/spec/spec.html) that is implemented using (but does **not** accept) regular expressions -- Request API for reading structs from JSON/XML and accesing 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](https://github.com/emicklei/go-restful-openapi), see [go-restful-swagger12](https://github.com/emicklei/go-restful-swagger12)) -- 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 - -## 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](https://github.com/json-iterator/go) by build this package using a tag, e.g. `go build -tags=jsoniter .` - -TODO: write examples of these. - -## Resources - -- [Example posted on blog](http://ernestmicklei.com/2012/11/go-restful-first-working-example/) -- [Design explained on blog](http://ernestmicklei.com/2012/11/go-restful-api-design/) -- [sourcegraph](https://sourcegraph.com/github.com/emicklei/go-restful) -- [showcase: Zazkia - tcp proxy for testing resiliency](https://github.com/emicklei/zazkia) -- [showcase: Mora - MongoDB REST Api server](https://github.com/emicklei/mora) - -Type ```git shortlog -s``` for a full list of contributors. - -© 2012 - 2020, http://ernestmicklei.com. MIT License. Contributions are welcome. diff --git a/vendor/github.com/emicklei/go-restful/Srcfile b/vendor/github.com/emicklei/go-restful/Srcfile deleted file mode 100644 index 16fd18689..000000000 --- a/vendor/github.com/emicklei/go-restful/Srcfile +++ /dev/null @@ -1 +0,0 @@ -{"SkipDirs": ["examples"]} diff --git a/vendor/github.com/emicklei/go-restful/bench_test.sh b/vendor/github.com/emicklei/go-restful/bench_test.sh deleted file mode 100644 index 47ffbe4ac..000000000 --- a/vendor/github.com/emicklei/go-restful/bench_test.sh +++ /dev/null @@ -1,10 +0,0 @@ -#go test -run=none -file bench_test.go -test.bench . -cpuprofile=bench_test.out - -go test -c -./go-restful.test -test.run=none -test.cpuprofile=tmp.prof -test.bench=BenchmarkMany -./go-restful.test -test.run=none -test.cpuprofile=curly.prof -test.bench=BenchmarkManyCurly - -#go tool pprof go-restful.test tmp.prof -go tool pprof go-restful.test curly.prof - - diff --git a/vendor/github.com/emicklei/go-restful/compress.go b/vendor/github.com/emicklei/go-restful/compress.go deleted file mode 100644 index 220b37712..000000000 --- a/vendor/github.com/emicklei/go-restful/compress.go +++ /dev/null @@ -1,123 +0,0 @@ -package restful - -// Copyright 2013 Ernest Micklei. All rights reserved. -// Use of this source code is governed by a license -// that can be found in the LICENSE file. - -import ( - "bufio" - "compress/gzip" - "compress/zlib" - "errors" - "io" - "net" - "net/http" - "strings" -) - -// OBSOLETE : use restful.DefaultContainer.EnableContentEncoding(true) to change this setting. -var EnableContentEncoding = false - -// CompressingResponseWriter is a http.ResponseWriter that can perform content encoding (gzip and zlib) -type CompressingResponseWriter struct { - writer http.ResponseWriter - compressor io.WriteCloser - encoding string -} - -// Header is part of http.ResponseWriter interface -func (c *CompressingResponseWriter) Header() http.Header { - return c.writer.Header() -} - -// WriteHeader is part of http.ResponseWriter interface -func (c *CompressingResponseWriter) WriteHeader(status int) { - c.writer.WriteHeader(status) -} - -// Write is part of http.ResponseWriter interface -// It is passed through the compressor -func (c *CompressingResponseWriter) Write(bytes []byte) (int, error) { - if c.isCompressorClosed() { - return -1, errors.New("Compressing error: tried to write data using closed compressor") - } - return c.compressor.Write(bytes) -} - -// CloseNotify is part of http.CloseNotifier interface -func (c *CompressingResponseWriter) CloseNotify() <-chan bool { - return c.writer.(http.CloseNotifier).CloseNotify() -} - -// Close the underlying compressor -func (c *CompressingResponseWriter) Close() error { - if c.isCompressorClosed() { - return errors.New("Compressing error: tried to close already closed compressor") - } - - c.compressor.Close() - if ENCODING_GZIP == c.encoding { - currentCompressorProvider.ReleaseGzipWriter(c.compressor.(*gzip.Writer)) - } - if ENCODING_DEFLATE == c.encoding { - currentCompressorProvider.ReleaseZlibWriter(c.compressor.(*zlib.Writer)) - } - // gc hint needed? - c.compressor = nil - return nil -} - -func (c *CompressingResponseWriter) isCompressorClosed() bool { - return nil == c.compressor -} - -// Hijack implements the Hijacker interface -// This is especially useful when combining Container.EnabledContentEncoding -// in combination with websockets (for instance gorilla/websocket) -func (c *CompressingResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { - hijacker, ok := c.writer.(http.Hijacker) - if !ok { - return nil, nil, errors.New("ResponseWriter doesn't support Hijacker interface") - } - return hijacker.Hijack() -} - -// WantsCompressedResponse reads the Accept-Encoding header to see if and which encoding is requested. -func wantsCompressedResponse(httpRequest *http.Request) (bool, string) { - header := httpRequest.Header.Get(HEADER_AcceptEncoding) - gi := strings.Index(header, ENCODING_GZIP) - zi := strings.Index(header, ENCODING_DEFLATE) - // use in order of appearance - if gi == -1 { - return zi != -1, ENCODING_DEFLATE - } else if zi == -1 { - return gi != -1, ENCODING_GZIP - } else { - if gi < zi { - return true, ENCODING_GZIP - } - return true, ENCODING_DEFLATE - } -} - -// NewCompressingResponseWriter create a CompressingResponseWriter for a known encoding = {gzip,deflate} -func NewCompressingResponseWriter(httpWriter http.ResponseWriter, encoding string) (*CompressingResponseWriter, error) { - httpWriter.Header().Set(HEADER_ContentEncoding, encoding) - c := new(CompressingResponseWriter) - c.writer = httpWriter - var err error - if ENCODING_GZIP == encoding { - w := currentCompressorProvider.AcquireGzipWriter() - w.Reset(httpWriter) - c.compressor = w - c.encoding = ENCODING_GZIP - } else if ENCODING_DEFLATE == encoding { - w := currentCompressorProvider.AcquireZlibWriter() - w.Reset(httpWriter) - c.compressor = w - c.encoding = ENCODING_DEFLATE - } else { - return nil, errors.New("Unknown encoding:" + encoding) - } - return c, err -} diff --git a/vendor/github.com/emicklei/go-restful/compressor_cache.go b/vendor/github.com/emicklei/go-restful/compressor_cache.go deleted file mode 100644 index ee426010a..000000000 --- a/vendor/github.com/emicklei/go-restful/compressor_cache.go +++ /dev/null @@ -1,103 +0,0 @@ -package restful - -// Copyright 2015 Ernest Micklei. All rights reserved. -// Use of this source code is governed by a license -// that can be found in the LICENSE file. - -import ( - "compress/gzip" - "compress/zlib" -) - -// BoundedCachedCompressors is a CompressorProvider that uses a cache with a fixed amount -// of writers and readers (resources). -// If a new resource is acquired and all are in use, it will return a new unmanaged resource. -type BoundedCachedCompressors struct { - gzipWriters chan *gzip.Writer - gzipReaders chan *gzip.Reader - zlibWriters chan *zlib.Writer - writersCapacity int - readersCapacity int -} - -// NewBoundedCachedCompressors returns a new, with filled cache, BoundedCachedCompressors. -func NewBoundedCachedCompressors(writersCapacity, readersCapacity int) *BoundedCachedCompressors { - b := &BoundedCachedCompressors{ - gzipWriters: make(chan *gzip.Writer, writersCapacity), - gzipReaders: make(chan *gzip.Reader, readersCapacity), - zlibWriters: make(chan *zlib.Writer, writersCapacity), - writersCapacity: writersCapacity, - readersCapacity: readersCapacity, - } - for ix := 0; ix < writersCapacity; ix++ { - b.gzipWriters <- newGzipWriter() - b.zlibWriters <- newZlibWriter() - } - for ix := 0; ix < readersCapacity; ix++ { - b.gzipReaders <- newGzipReader() - } - return b -} - -// AcquireGzipWriter returns an resettable *gzip.Writer. Needs to be released. -func (b *BoundedCachedCompressors) AcquireGzipWriter() *gzip.Writer { - var writer *gzip.Writer - select { - case writer, _ = <-b.gzipWriters: - default: - // return a new unmanaged one - writer = newGzipWriter() - } - return writer -} - -// ReleaseGzipWriter accepts a writer (does not have to be one that was cached) -// only when the cache has room for it. It will ignore it otherwise. -func (b *BoundedCachedCompressors) ReleaseGzipWriter(w *gzip.Writer) { - // forget the unmanaged ones - if len(b.gzipWriters) < b.writersCapacity { - b.gzipWriters <- w - } -} - -// AcquireGzipReader returns a *gzip.Reader. Needs to be released. -func (b *BoundedCachedCompressors) AcquireGzipReader() *gzip.Reader { - var reader *gzip.Reader - select { - case reader, _ = <-b.gzipReaders: - default: - // return a new unmanaged one - reader = newGzipReader() - } - return reader -} - -// ReleaseGzipReader accepts a reader (does not have to be one that was cached) -// only when the cache has room for it. It will ignore it otherwise. -func (b *BoundedCachedCompressors) ReleaseGzipReader(r *gzip.Reader) { - // forget the unmanaged ones - if len(b.gzipReaders) < b.readersCapacity { - b.gzipReaders <- r - } -} - -// AcquireZlibWriter returns an resettable *zlib.Writer. Needs to be released. -func (b *BoundedCachedCompressors) AcquireZlibWriter() *zlib.Writer { - var writer *zlib.Writer - select { - case writer, _ = <-b.zlibWriters: - default: - // return a new unmanaged one - writer = newZlibWriter() - } - return writer -} - -// ReleaseZlibWriter accepts a writer (does not have to be one that was cached) -// only when the cache has room for it. It will ignore it otherwise. -func (b *BoundedCachedCompressors) ReleaseZlibWriter(w *zlib.Writer) { - // forget the unmanaged ones - if len(b.zlibWriters) < b.writersCapacity { - b.zlibWriters <- w - } -} diff --git a/vendor/github.com/emicklei/go-restful/compressor_pools.go b/vendor/github.com/emicklei/go-restful/compressor_pools.go deleted file mode 100644 index d866ce64b..000000000 --- a/vendor/github.com/emicklei/go-restful/compressor_pools.go +++ /dev/null @@ -1,91 +0,0 @@ -package restful - -// Copyright 2015 Ernest Micklei. All rights reserved. -// Use of this source code is governed by a license -// that can be found in the LICENSE file. - -import ( - "bytes" - "compress/gzip" - "compress/zlib" - "sync" -) - -// SyncPoolCompessors is a CompressorProvider that use the standard sync.Pool. -type SyncPoolCompessors struct { - GzipWriterPool *sync.Pool - GzipReaderPool *sync.Pool - ZlibWriterPool *sync.Pool -} - -// NewSyncPoolCompessors returns a new ("empty") SyncPoolCompessors. -func NewSyncPoolCompessors() *SyncPoolCompessors { - return &SyncPoolCompessors{ - GzipWriterPool: &sync.Pool{ - New: func() interface{} { return newGzipWriter() }, - }, - GzipReaderPool: &sync.Pool{ - New: func() interface{} { return newGzipReader() }, - }, - ZlibWriterPool: &sync.Pool{ - New: func() interface{} { return newZlibWriter() }, - }, - } -} - -func (s *SyncPoolCompessors) AcquireGzipWriter() *gzip.Writer { - return s.GzipWriterPool.Get().(*gzip.Writer) -} - -func (s *SyncPoolCompessors) ReleaseGzipWriter(w *gzip.Writer) { - s.GzipWriterPool.Put(w) -} - -func (s *SyncPoolCompessors) AcquireGzipReader() *gzip.Reader { - return s.GzipReaderPool.Get().(*gzip.Reader) -} - -func (s *SyncPoolCompessors) ReleaseGzipReader(r *gzip.Reader) { - s.GzipReaderPool.Put(r) -} - -func (s *SyncPoolCompessors) AcquireZlibWriter() *zlib.Writer { - return s.ZlibWriterPool.Get().(*zlib.Writer) -} - -func (s *SyncPoolCompessors) ReleaseZlibWriter(w *zlib.Writer) { - s.ZlibWriterPool.Put(w) -} - -func newGzipWriter() *gzip.Writer { - // create with an empty bytes writer; it will be replaced before using the gzipWriter - writer, err := gzip.NewWriterLevel(new(bytes.Buffer), gzip.BestSpeed) - if err != nil { - panic(err.Error()) - } - return writer -} - -func newGzipReader() *gzip.Reader { - // create with an empty reader (but with GZIP header); it will be replaced before using the gzipReader - // we can safely use currentCompressProvider because it is set on package initialization. - w := currentCompressorProvider.AcquireGzipWriter() - defer currentCompressorProvider.ReleaseGzipWriter(w) - b := new(bytes.Buffer) - w.Reset(b) - w.Flush() - w.Close() - reader, err := gzip.NewReader(bytes.NewReader(b.Bytes())) - if err != nil { - panic(err.Error()) - } - return reader -} - -func newZlibWriter() *zlib.Writer { - writer, err := zlib.NewWriterLevel(new(bytes.Buffer), gzip.BestSpeed) - if err != nil { - panic(err.Error()) - } - return writer -} diff --git a/vendor/github.com/emicklei/go-restful/compressors.go b/vendor/github.com/emicklei/go-restful/compressors.go deleted file mode 100644 index 9db4a8c8e..000000000 --- a/vendor/github.com/emicklei/go-restful/compressors.go +++ /dev/null @@ -1,54 +0,0 @@ -package restful - -// Copyright 2015 Ernest Micklei. All rights reserved. -// Use of this source code is governed by a license -// that can be found in the LICENSE file. - -import ( - "compress/gzip" - "compress/zlib" -) - -// CompressorProvider describes a component that can provider compressors for the std methods. -type CompressorProvider interface { - // Returns a *gzip.Writer which needs to be released later. - // Before using it, call Reset(). - AcquireGzipWriter() *gzip.Writer - - // Releases an acquired *gzip.Writer. - ReleaseGzipWriter(w *gzip.Writer) - - // Returns a *gzip.Reader which needs to be released later. - AcquireGzipReader() *gzip.Reader - - // Releases an acquired *gzip.Reader. - ReleaseGzipReader(w *gzip.Reader) - - // Returns a *zlib.Writer which needs to be released later. - // Before using it, call Reset(). - AcquireZlibWriter() *zlib.Writer - - // Releases an acquired *zlib.Writer. - ReleaseZlibWriter(w *zlib.Writer) -} - -// DefaultCompressorProvider is the actual provider of compressors (zlib or gzip). -var currentCompressorProvider CompressorProvider - -func init() { - currentCompressorProvider = NewSyncPoolCompessors() -} - -// CurrentCompressorProvider returns the current CompressorProvider. -// It is initialized using a SyncPoolCompessors. -func CurrentCompressorProvider() CompressorProvider { - return currentCompressorProvider -} - -// SetCompressorProvider sets the actual provider of compressors (zlib or gzip). -func SetCompressorProvider(p CompressorProvider) { - if p == nil { - panic("cannot set compressor provider to nil") - } - currentCompressorProvider = p -} diff --git a/vendor/github.com/emicklei/go-restful/constants.go b/vendor/github.com/emicklei/go-restful/constants.go deleted file mode 100644 index 203439c5e..000000000 --- a/vendor/github.com/emicklei/go-restful/constants.go +++ /dev/null @@ -1,30 +0,0 @@ -package restful - -// Copyright 2013 Ernest Micklei. All rights reserved. -// Use of this source code is governed by a license -// that can be found in the LICENSE file. - -const ( - MIME_XML = "application/xml" // Accept or Content-Type used in Consumes() and/or Produces() - MIME_JSON = "application/json" // Accept or Content-Type used in Consumes() and/or Produces() - MIME_OCTET = "application/octet-stream" // If Content-Type is not present in request, use the default - - HEADER_Allow = "Allow" - HEADER_Accept = "Accept" - HEADER_Origin = "Origin" - HEADER_ContentType = "Content-Type" - HEADER_LastModified = "Last-Modified" - HEADER_AcceptEncoding = "Accept-Encoding" - HEADER_ContentEncoding = "Content-Encoding" - HEADER_AccessControlExposeHeaders = "Access-Control-Expose-Headers" - HEADER_AccessControlRequestMethod = "Access-Control-Request-Method" - HEADER_AccessControlRequestHeaders = "Access-Control-Request-Headers" - HEADER_AccessControlAllowMethods = "Access-Control-Allow-Methods" - HEADER_AccessControlAllowOrigin = "Access-Control-Allow-Origin" - HEADER_AccessControlAllowCredentials = "Access-Control-Allow-Credentials" - HEADER_AccessControlAllowHeaders = "Access-Control-Allow-Headers" - HEADER_AccessControlMaxAge = "Access-Control-Max-Age" - - ENCODING_GZIP = "gzip" - ENCODING_DEFLATE = "deflate" -) diff --git a/vendor/github.com/emicklei/go-restful/container.go b/vendor/github.com/emicklei/go-restful/container.go deleted file mode 100644 index afca312a4..000000000 --- a/vendor/github.com/emicklei/go-restful/container.go +++ /dev/null @@ -1,445 +0,0 @@ -package restful - -// Copyright 2013 Ernest Micklei. All rights reserved. -// Use of this source code is governed by a license -// that can be found in the LICENSE file. - -import ( - "bytes" - "errors" - "fmt" - "net/http" - "os" - "runtime" - "strings" - "sync" - - "github.com/emicklei/go-restful/log" -) - -// Container holds a collection of WebServices and a http.ServeMux to dispatch http requests. -// The requests are further dispatched to routes of WebServices using a RouteSelector -type Container struct { - webServicesLock sync.RWMutex - webServices []*WebService - ServeMux *http.ServeMux - isRegisteredOnRoot bool - containerFilters []FilterFunction - doNotRecover bool // default is true - recoverHandleFunc RecoverHandleFunction - serviceErrorHandleFunc ServiceErrorHandleFunction - router RouteSelector // default is a CurlyRouter (RouterJSR311 is a slower alternative) - contentEncodingEnabled bool // default is false -} - -// NewContainer creates a new Container using a new ServeMux and default router (CurlyRouter) -func NewContainer() *Container { - return &Container{ - webServices: []*WebService{}, - ServeMux: http.NewServeMux(), - isRegisteredOnRoot: false, - containerFilters: []FilterFunction{}, - doNotRecover: true, - recoverHandleFunc: logStackOnRecover, - serviceErrorHandleFunc: writeServiceError, - router: CurlyRouter{}, - contentEncodingEnabled: false} -} - -// RecoverHandleFunction declares functions that can be used to handle a panic situation. -// The first argument is what recover() returns. The second must be used to communicate an error response. -type RecoverHandleFunction func(interface{}, http.ResponseWriter) - -// RecoverHandler changes the default function (logStackOnRecover) to be called -// when a panic is detected. DoNotRecover must be have its default value (=false). -func (c *Container) RecoverHandler(handler RecoverHandleFunction) { - c.recoverHandleFunc = handler -} - -// ServiceErrorHandleFunction declares functions that can be used to handle a service error situation. -// The first argument is the service error, the second is the request that resulted in the error and -// the third must be used to communicate an error response. -type ServiceErrorHandleFunction func(ServiceError, *Request, *Response) - -// ServiceErrorHandler changes the default function (writeServiceError) to be called -// when a ServiceError is detected. -func (c *Container) ServiceErrorHandler(handler ServiceErrorHandleFunction) { - c.serviceErrorHandleFunc = handler -} - -// DoNotRecover controls whether panics will be caught to return HTTP 500. -// If set to true, Route functions are responsible for handling any error situation. -// Default value is true. -func (c *Container) DoNotRecover(doNot bool) { - c.doNotRecover = doNot -} - -// Router changes the default Router (currently CurlyRouter) -func (c *Container) Router(aRouter RouteSelector) { - c.router = aRouter -} - -// EnableContentEncoding (default=false) allows for GZIP or DEFLATE encoding of responses. -func (c *Container) EnableContentEncoding(enabled bool) { - c.contentEncodingEnabled = enabled -} - -// Add a WebService to the Container. It will detect duplicate root paths and exit in that case. -func (c *Container) Add(service *WebService) *Container { - c.webServicesLock.Lock() - defer c.webServicesLock.Unlock() - - // if rootPath was not set then lazy initialize it - if len(service.rootPath) == 0 { - service.Path("/") - } - - // cannot have duplicate root paths - for _, each := range c.webServices { - if each.RootPath() == service.RootPath() { - log.Printf("WebService with duplicate root path detected:['%v']", each) - os.Exit(1) - } - } - - // If not registered on root then add specific mapping - if !c.isRegisteredOnRoot { - c.isRegisteredOnRoot = c.addHandler(service, c.ServeMux) - } - c.webServices = append(c.webServices, service) - return c -} - -// addHandler may set a new HandleFunc for the serveMux -// this function must run inside the critical region protected by the webServicesLock. -// returns true if the function was registered on root ("/") -func (c *Container) addHandler(service *WebService, serveMux *http.ServeMux) bool { - pattern := fixedPrefixPath(service.RootPath()) - // check if root path registration is needed - if "/" == pattern || "" == pattern { - serveMux.HandleFunc("/", c.dispatch) - return true - } - // detect if registration already exists - alreadyMapped := false - for _, each := range c.webServices { - if each.RootPath() == service.RootPath() { - alreadyMapped = true - break - } - } - if !alreadyMapped { - serveMux.HandleFunc(pattern, c.dispatch) - if !strings.HasSuffix(pattern, "/") { - serveMux.HandleFunc(pattern+"/", c.dispatch) - } - } - return false -} - -func (c *Container) Remove(ws *WebService) error { - if c.ServeMux == http.DefaultServeMux { - errMsg := fmt.Sprintf("cannot remove a WebService from a Container using the DefaultServeMux: ['%v']", ws) - log.Print(errMsg) - return errors.New(errMsg) - } - c.webServicesLock.Lock() - defer c.webServicesLock.Unlock() - // build a new ServeMux and re-register all WebServices - newServeMux := http.NewServeMux() - newServices := []*WebService{} - newIsRegisteredOnRoot := false - for _, each := range c.webServices { - if each.rootPath != ws.rootPath { - // If not registered on root then add specific mapping - if !newIsRegisteredOnRoot { - newIsRegisteredOnRoot = c.addHandler(each, newServeMux) - } - newServices = append(newServices, each) - } - } - c.webServices, c.ServeMux, c.isRegisteredOnRoot = newServices, newServeMux, newIsRegisteredOnRoot - return nil -} - -// logStackOnRecover is the default RecoverHandleFunction and is called -// when DoNotRecover is false and the recoverHandleFunc is not set for the container. -// Default implementation logs the stacktrace and writes the stacktrace on the response. -// This may be a security issue as it exposes sourcecode information. -func logStackOnRecover(panicReason interface{}, httpWriter http.ResponseWriter) { - var buffer bytes.Buffer - buffer.WriteString(fmt.Sprintf("recover from panic situation: - %v\r\n", panicReason)) - for i := 2; ; i += 1 { - _, file, line, ok := runtime.Caller(i) - if !ok { - break - } - buffer.WriteString(fmt.Sprintf(" %s:%d\r\n", file, line)) - } - log.Print(buffer.String()) - httpWriter.WriteHeader(http.StatusInternalServerError) - httpWriter.Write(buffer.Bytes()) -} - -// writeServiceError is the default ServiceErrorHandleFunction and is called -// when a ServiceError is returned during route selection. Default implementation -// calls resp.WriteErrorString(err.Code, err.Message) -func writeServiceError(err ServiceError, req *Request, resp *Response) { - for header, values := range err.Header { - for _, value := range values { - resp.Header().Add(header, value) - } - } - resp.WriteErrorString(err.Code, err.Message) -} - -// Dispatch the incoming Http Request to a matching WebService. -func (c *Container) Dispatch(httpWriter http.ResponseWriter, httpRequest *http.Request) { - if httpWriter == nil { - panic("httpWriter cannot be nil") - } - if httpRequest == nil { - panic("httpRequest cannot be nil") - } - c.dispatch(httpWriter, httpRequest) -} - -// Dispatch the incoming Http Request to a matching WebService. -func (c *Container) dispatch(httpWriter http.ResponseWriter, httpRequest *http.Request) { - // so we can assign a compressing one later - writer := httpWriter - - // CompressingResponseWriter should be closed after all operations are done - defer func() { - if compressWriter, ok := writer.(*CompressingResponseWriter); ok { - compressWriter.Close() - } - }() - - // Instal panic recovery unless told otherwise - if !c.doNotRecover { // catch all for 500 response - defer func() { - if r := recover(); r != nil { - c.recoverHandleFunc(r, writer) - return - } - }() - } - - // Find best match Route ; err is non nil if no match was found - var webService *WebService - var route *Route - var err error - func() { - c.webServicesLock.RLock() - defer c.webServicesLock.RUnlock() - webService, route, err = c.router.SelectRoute( - c.webServices, - httpRequest) - }() - if err != nil { - // a non-200 response (may be compressed) has already been written - // run container filters anyway ; they should not touch the response... - chain := FilterChain{Filters: c.containerFilters, Target: func(req *Request, resp *Response) { - switch err.(type) { - case ServiceError: - ser := err.(ServiceError) - c.serviceErrorHandleFunc(ser, req, resp) - } - // TODO - }} - chain.ProcessFilter(NewRequest(httpRequest), NewResponse(writer)) - return - } - - // Unless httpWriter is already an CompressingResponseWriter see if we need to install one - if _, isCompressing := httpWriter.(*CompressingResponseWriter); !isCompressing { - // Detect if compression is needed - // assume without compression, test for override - contentEncodingEnabled := c.contentEncodingEnabled - if route != nil && route.contentEncodingEnabled != nil { - contentEncodingEnabled = *route.contentEncodingEnabled - } - if contentEncodingEnabled { - doCompress, encoding := wantsCompressedResponse(httpRequest) - if doCompress { - var err error - writer, err = NewCompressingResponseWriter(httpWriter, encoding) - if err != nil { - log.Print("unable to install compressor: ", err) - httpWriter.WriteHeader(http.StatusInternalServerError) - return - } - } - } - } - - pathProcessor, routerProcessesPath := c.router.(PathProcessor) - if !routerProcessesPath { - pathProcessor = defaultPathProcessor{} - } - pathParams := pathProcessor.ExtractParameters(route, webService, httpRequest.URL.Path) - wrappedRequest, wrappedResponse := route.wrapRequestResponse(writer, httpRequest, pathParams) - // pass through filters (if any) - if size := len(c.containerFilters) + len(webService.filters) + len(route.Filters); size > 0 { - // compose filter chain - allFilters := make([]FilterFunction, 0, size) - allFilters = append(allFilters, c.containerFilters...) - allFilters = append(allFilters, webService.filters...) - allFilters = append(allFilters, route.Filters...) - chain := FilterChain{Filters: allFilters, Target: route.Function} - chain.ProcessFilter(wrappedRequest, wrappedResponse) - } else { - // no filters, handle request by route - route.Function(wrappedRequest, wrappedResponse) - } -} - -// fixedPrefixPath returns the fixed part of the partspec ; it may include template vars {} -func fixedPrefixPath(pathspec string) string { - varBegin := strings.Index(pathspec, "{") - if -1 == varBegin { - return pathspec - } - return pathspec[:varBegin] -} - -// ServeHTTP implements net/http.Handler therefore a Container can be a Handler in a http.Server -func (c *Container) ServeHTTP(httpWriter http.ResponseWriter, httpRequest *http.Request) { - // Skip, if content encoding is disabled - if !c.contentEncodingEnabled { - c.ServeMux.ServeHTTP(httpWriter, httpRequest) - return - } - // content encoding is enabled - - // Skip, if httpWriter is already an CompressingResponseWriter - if _, ok := httpWriter.(*CompressingResponseWriter); ok { - c.ServeMux.ServeHTTP(httpWriter, httpRequest) - return - } - - writer := httpWriter - // CompressingResponseWriter should be closed after all operations are done - defer func() { - if compressWriter, ok := writer.(*CompressingResponseWriter); ok { - compressWriter.Close() - } - }() - - doCompress, encoding := wantsCompressedResponse(httpRequest) - if doCompress { - var err error - writer, err = NewCompressingResponseWriter(httpWriter, encoding) - if err != nil { - log.Print("unable to install compressor: ", err) - httpWriter.WriteHeader(http.StatusInternalServerError) - return - } - } - - c.ServeMux.ServeHTTP(writer, httpRequest) -} - -// Handle registers the handler for the given pattern. If a handler already exists for pattern, Handle panics. -func (c *Container) Handle(pattern string, handler http.Handler) { - c.ServeMux.Handle(pattern, http.HandlerFunc(func(httpWriter http.ResponseWriter, httpRequest *http.Request) { - // Skip, if httpWriter is already an CompressingResponseWriter - if _, ok := httpWriter.(*CompressingResponseWriter); ok { - handler.ServeHTTP(httpWriter, httpRequest) - return - } - - writer := httpWriter - - // CompressingResponseWriter should be closed after all operations are done - defer func() { - if compressWriter, ok := writer.(*CompressingResponseWriter); ok { - compressWriter.Close() - } - }() - - if c.contentEncodingEnabled { - doCompress, encoding := wantsCompressedResponse(httpRequest) - if doCompress { - var err error - writer, err = NewCompressingResponseWriter(httpWriter, encoding) - if err != nil { - log.Print("unable to install compressor: ", err) - httpWriter.WriteHeader(http.StatusInternalServerError) - return - } - } - } - - handler.ServeHTTP(writer, httpRequest) - })) -} - -// HandleWithFilter registers the handler for the given pattern. -// Container's filter chain is applied for handler. -// If a handler already exists for pattern, HandleWithFilter panics. -func (c *Container) HandleWithFilter(pattern string, handler http.Handler) { - f := func(httpResponse http.ResponseWriter, httpRequest *http.Request) { - if len(c.containerFilters) == 0 { - handler.ServeHTTP(httpResponse, httpRequest) - return - } - - chain := FilterChain{Filters: c.containerFilters, Target: func(req *Request, resp *Response) { - handler.ServeHTTP(resp, req.Request) - }} - chain.ProcessFilter(NewRequest(httpRequest), NewResponse(httpResponse)) - } - - c.Handle(pattern, http.HandlerFunc(f)) -} - -// Filter appends a container FilterFunction. These are called before dispatching -// a http.Request to a WebService from the container -func (c *Container) Filter(filter FilterFunction) { - c.containerFilters = append(c.containerFilters, filter) -} - -// RegisteredWebServices returns the collections of added WebServices -func (c *Container) RegisteredWebServices() []*WebService { - c.webServicesLock.RLock() - defer c.webServicesLock.RUnlock() - result := make([]*WebService, len(c.webServices)) - for ix := range c.webServices { - result[ix] = c.webServices[ix] - } - return result -} - -// computeAllowedMethods returns a list of HTTP methods that are valid for a Request -func (c *Container) computeAllowedMethods(req *Request) []string { - // Go through all RegisteredWebServices() and all its Routes to collect the options - methods := []string{} - requestPath := req.Request.URL.Path - for _, ws := range c.RegisteredWebServices() { - matches := ws.pathExpr.Matcher.FindStringSubmatch(requestPath) - if matches != nil { - finalMatch := matches[len(matches)-1] - for _, rt := range ws.Routes() { - matches := rt.pathExpr.Matcher.FindStringSubmatch(finalMatch) - if matches != nil { - lastMatch := matches[len(matches)-1] - if lastMatch == "" || lastMatch == "/" { // do not include if value is neither empty nor ‘/’. - methods = append(methods, rt.Method) - } - } - } - } - } - // methods = append(methods, "OPTIONS") not sure about this - return methods -} - -// newBasicRequestResponse creates a pair of Request,Response from its http versions. -// It is basic because no parameter or (produces) content-type information is given. -func newBasicRequestResponse(httpWriter http.ResponseWriter, httpRequest *http.Request) (*Request, *Response) { - resp := NewResponse(httpWriter) - resp.requestAccept = httpRequest.Header.Get(HEADER_Accept) - return NewRequest(httpRequest), resp -} diff --git a/vendor/github.com/emicklei/go-restful/cors_filter.go b/vendor/github.com/emicklei/go-restful/cors_filter.go deleted file mode 100644 index 9d18dfb7b..000000000 --- a/vendor/github.com/emicklei/go-restful/cors_filter.go +++ /dev/null @@ -1,193 +0,0 @@ -package restful - -// Copyright 2013 Ernest Micklei. All rights reserved. -// Use of this source code is governed by a license -// that can be found in the LICENSE file. - -import ( - "regexp" - "strconv" - "strings" -) - -// CrossOriginResourceSharing is used to create a Container Filter that implements CORS. -// Cross-origin resource sharing (CORS) is a mechanism that allows JavaScript on a web page -// to make XMLHttpRequests to another domain, not the domain the JavaScript originated from. -// -// http://en.wikipedia.org/wiki/Cross-origin_resource_sharing -// 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 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 - Container *Container - - allowedOriginPatterns []*regexp.Regexp // internal field for origin regexp check. -} - -// Filter is a filter function that implements the CORS flow as documented on http://enable-cors.org/server.html -// and http://www.html5rocks.com/static/images/cors_server_flowchart.png -func (c CrossOriginResourceSharing) Filter(req *Request, resp *Response, chain *FilterChain) { - origin := req.Request.Header.Get(HEADER_Origin) - if len(origin) == 0 { - if trace { - traceLogger.Print("no Http header Origin set") - } - chain.ProcessFilter(req, resp) - return - } - if !c.isOriginAllowed(origin) { // check whether this origin is allowed - if trace { - traceLogger.Printf("HTTP Origin:%s is not part of %v, neither matches any part of %v", origin, c.AllowedDomains, c.allowedOriginPatterns) - } - chain.ProcessFilter(req, resp) - return - } - if req.Request.Method != "OPTIONS" { - c.doActualRequest(req, resp) - chain.ProcessFilter(req, resp) - return - } - if acrm := req.Request.Header.Get(HEADER_AccessControlRequestMethod); acrm != "" { - c.doPreflightRequest(req, resp) - } else { - c.doActualRequest(req, resp) - chain.ProcessFilter(req, resp) - return - } -} - -func (c CrossOriginResourceSharing) doActualRequest(req *Request, resp *Response) { - c.setOptionsHeaders(req, resp) - // continue processing the response -} - -func (c *CrossOriginResourceSharing) doPreflightRequest(req *Request, resp *Response) { - if len(c.AllowedMethods) == 0 { - if c.Container == nil { - c.AllowedMethods = DefaultContainer.computeAllowedMethods(req) - } else { - c.AllowedMethods = c.Container.computeAllowedMethods(req) - } - } - - acrm := req.Request.Header.Get(HEADER_AccessControlRequestMethod) - if !c.isValidAccessControlRequestMethod(acrm, c.AllowedMethods) { - if trace { - traceLogger.Printf("Http header %s:%s is not in %v", - HEADER_AccessControlRequestMethod, - acrm, - c.AllowedMethods) - } - return - } - acrhs := req.Request.Header.Get(HEADER_AccessControlRequestHeaders) - if len(acrhs) > 0 { - for _, each := range strings.Split(acrhs, ",") { - if !c.isValidAccessControlRequestHeader(strings.Trim(each, " ")) { - if trace { - traceLogger.Printf("Http header %s:%s is not in %v", - HEADER_AccessControlRequestHeaders, - acrhs, - c.AllowedHeaders) - } - return - } - } - } - resp.AddHeader(HEADER_AccessControlAllowMethods, strings.Join(c.AllowedMethods, ",")) - resp.AddHeader(HEADER_AccessControlAllowHeaders, acrhs) - c.setOptionsHeaders(req, resp) - - // return http 200 response, no body -} - -func (c CrossOriginResourceSharing) setOptionsHeaders(req *Request, resp *Response) { - c.checkAndSetExposeHeaders(resp) - c.setAllowOriginHeader(req, resp) - c.checkAndSetAllowCredentials(resp) - if c.MaxAge > 0 { - resp.AddHeader(HEADER_AccessControlMaxAge, strconv.Itoa(c.MaxAge)) - } -} - -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 - } - - // exact match on each allowed domain - for _, domain := range c.AllowedDomains { - if domain == ".*" || strings.ToLower(domain) == lowerOrigin { - return true - } - } - if c.AllowedDomainFunc != nil { - return c.AllowedDomainFunc(origin) - } - return false -} - -func (c CrossOriginResourceSharing) setAllowOriginHeader(req *Request, resp *Response) { - origin := req.Request.Header.Get(HEADER_Origin) - if c.isOriginAllowed(origin) { - resp.AddHeader(HEADER_AccessControlAllowOrigin, origin) - } -} - -func (c CrossOriginResourceSharing) checkAndSetExposeHeaders(resp *Response) { - if len(c.ExposeHeaders) > 0 { - resp.AddHeader(HEADER_AccessControlExposeHeaders, strings.Join(c.ExposeHeaders, ",")) - } -} - -func (c CrossOriginResourceSharing) checkAndSetAllowCredentials(resp *Response) { - if c.CookiesAllowed { - resp.AddHeader(HEADER_AccessControlAllowCredentials, "true") - } -} - -func (c CrossOriginResourceSharing) isValidAccessControlRequestMethod(method string, allowedMethods []string) bool { - for _, each := range allowedMethods { - if each == method { - return true - } - } - return false -} - -func (c CrossOriginResourceSharing) isValidAccessControlRequestHeader(header string) bool { - for _, each := range c.AllowedHeaders { - if strings.ToLower(each) == strings.ToLower(header) { - return true - } - if each == "*" { - return true - } - } - return false -} diff --git a/vendor/github.com/emicklei/go-restful/coverage.sh b/vendor/github.com/emicklei/go-restful/coverage.sh deleted file mode 100644 index e27dbf1a9..000000000 --- a/vendor/github.com/emicklei/go-restful/coverage.sh +++ /dev/null @@ -1,2 +0,0 @@ -go test -coverprofile=coverage.out -go tool cover -html=coverage.out \ No newline at end of file diff --git a/vendor/github.com/emicklei/go-restful/curly.go b/vendor/github.com/emicklei/go-restful/curly.go deleted file mode 100644 index ba1fc5d5f..000000000 --- a/vendor/github.com/emicklei/go-restful/curly.go +++ /dev/null @@ -1,173 +0,0 @@ -package restful - -// Copyright 2013 Ernest Micklei. All rights reserved. -// Use of this source code is governed by a license -// that can be found in the LICENSE file. - -import ( - "net/http" - "regexp" - "sort" - "strings" -) - -// CurlyRouter expects Routes with paths that contain zero or more parameters in curly brackets. -type CurlyRouter struct{} - -// SelectRoute is part of the Router interface and returns the best match -// for the WebService and its Route for the given Request. -func (c CurlyRouter) SelectRoute( - webServices []*WebService, - httpRequest *http.Request) (selectedService *WebService, selected *Route, err error) { - - requestTokens := tokenizePath(httpRequest.URL.Path) - - detectedService := c.detectWebService(requestTokens, webServices) - if detectedService == nil { - if trace { - traceLogger.Printf("no WebService was found to match URL path:%s\n", httpRequest.URL.Path) - } - return nil, nil, NewError(http.StatusNotFound, "404: Page Not Found") - } - candidateRoutes := c.selectRoutes(detectedService, requestTokens) - if len(candidateRoutes) == 0 { - if trace { - traceLogger.Printf("no Route in WebService with path %s was found to match URL path:%s\n", detectedService.rootPath, httpRequest.URL.Path) - } - return detectedService, nil, NewError(http.StatusNotFound, "404: Page Not Found") - } - selectedRoute, err := c.detectRoute(candidateRoutes, httpRequest) - if selectedRoute == nil { - return detectedService, nil, err - } - return detectedService, selectedRoute, nil -} - -// selectRoutes return a collection of Route from a WebService that matches the path tokens from the request. -func (c CurlyRouter) selectRoutes(ws *WebService, requestTokens []string) sortableCurlyRoutes { - candidates := make(sortableCurlyRoutes, 0, 8) - for _, each := range ws.routes { - matches, paramCount, staticCount := c.matchesRouteByPathTokens(each.pathParts, requestTokens, each.hasCustomVerb) - if matches { - candidates.add(curlyRoute{each, paramCount, staticCount}) // TODO make sure Routes() return pointers? - } - } - sort.Sort(candidates) - return candidates -} - -// matchesRouteByPathTokens computes whether it matches, howmany parameters do match and what the number of static path elements are. -func (c CurlyRouter) matchesRouteByPathTokens(routeTokens, requestTokens []string, routeHasCustomVerb bool) (matches bool, paramCount int, staticCount int) { - if len(routeTokens) < len(requestTokens) { - // proceed in matching only if last routeToken is wildcard - count := len(routeTokens) - if count == 0 || !strings.HasSuffix(routeTokens[count-1], "*}") { - return false, 0, 0 - } - // proceed - } - for i, routeToken := range routeTokens { - if i == len(requestTokens) { - // reached end of request path - return false, 0, 0 - } - requestToken := requestTokens[i] - if routeHasCustomVerb && hasCustomVerb(routeToken){ - if !isMatchCustomVerb(routeToken, requestToken) { - return false, 0, 0 - } - staticCount++ - requestToken = removeCustomVerb(requestToken) - routeToken = removeCustomVerb(routeToken) - } - - if strings.HasPrefix(routeToken, "{") { - paramCount++ - if colon := strings.Index(routeToken, ":"); colon != -1 { - // match by regex - matchesToken, matchesRemainder := c.regularMatchesPathToken(routeToken, colon, requestToken) - if !matchesToken { - return false, 0, 0 - } - if matchesRemainder { - break - } - } - } else { // no { prefix - if requestToken != routeToken { - return false, 0, 0 - } - staticCount++ - } - } - return true, paramCount, staticCount -} - -// regularMatchesPathToken tests whether the regular expression part of routeToken matches the requestToken or all remaining tokens -// format routeToken is {someVar:someExpression}, e.g. {zipcode:[\d][\d][\d][\d][A-Z][A-Z]} -func (c CurlyRouter) regularMatchesPathToken(routeToken string, colon int, requestToken string) (matchesToken bool, matchesRemainder bool) { - regPart := routeToken[colon+1 : len(routeToken)-1] - if regPart == "*" { - if trace { - traceLogger.Printf("wildcard parameter detected in route token %s that matches %s\n", routeToken, requestToken) - } - return true, true - } - matched, err := regexp.MatchString(regPart, requestToken) - return (matched && err == nil), false -} - -var jsr311Router = RouterJSR311{} - -// detectRoute selectes from a list of Route the first match by inspecting both the Accept and Content-Type -// headers of the Request. See also RouterJSR311 in jsr311.go -func (c CurlyRouter) detectRoute(candidateRoutes sortableCurlyRoutes, httpRequest *http.Request) (*Route, error) { - // tracing is done inside detectRoute - return jsr311Router.detectRoute(candidateRoutes.routes(), httpRequest) -} - -// detectWebService returns the best matching webService given the list of path tokens. -// see also computeWebserviceScore -func (c CurlyRouter) detectWebService(requestTokens []string, webServices []*WebService) *WebService { - var best *WebService - score := -1 - for _, each := range webServices { - matches, eachScore := c.computeWebserviceScore(requestTokens, each.pathExpr.tokens) - if matches && (eachScore > score) { - best = each - score = eachScore - } - } - return best -} - -// computeWebserviceScore returns whether tokens match and -// the weighted score of the longest matching consecutive tokens from the beginning. -func (c CurlyRouter) computeWebserviceScore(requestTokens []string, tokens []string) (bool, int) { - if len(tokens) > len(requestTokens) { - return false, 0 - } - score := 0 - for i := 0; i < len(tokens); i++ { - each := requestTokens[i] - other := tokens[i] - if len(each) == 0 && len(other) == 0 { - score++ - continue - } - if len(other) > 0 && strings.HasPrefix(other, "{") { - // no empty match - if len(each) == 0 { - return false, score - } - score += 1 - } else { - // not a parameter - if each != other { - return false, score - } - score += (len(tokens) - i) * 10 //fuzzy - } - } - return true, score -} diff --git a/vendor/github.com/emicklei/go-restful/curly_route.go b/vendor/github.com/emicklei/go-restful/curly_route.go deleted file mode 100644 index 403dd3be9..000000000 --- a/vendor/github.com/emicklei/go-restful/curly_route.go +++ /dev/null @@ -1,54 +0,0 @@ -package restful - -// Copyright 2013 Ernest Micklei. All rights reserved. -// Use of this source code is governed by a license -// that can be found in the LICENSE file. - -// curlyRoute exits for sorting Routes by the CurlyRouter based on number of parameters and number of static path elements. -type curlyRoute struct { - route Route - paramCount int - staticCount int -} - -// sortableCurlyRoutes orders by most parameters and path elements first. -type sortableCurlyRoutes []curlyRoute - -func (s *sortableCurlyRoutes) add(route curlyRoute) { - *s = append(*s, route) -} - -func (s sortableCurlyRoutes) routes() (routes []Route) { - routes = make([]Route, 0, len(s)) - for _, each := range s { - routes = append(routes, each.route) // TODO change return type - } - return routes -} - -func (s sortableCurlyRoutes) Len() int { - return len(s) -} -func (s sortableCurlyRoutes) Swap(i, j int) { - s[i], s[j] = s[j], s[i] -} -func (s sortableCurlyRoutes) Less(i, j int) bool { - a := s[j] - b := s[i] - - // primary key - if a.staticCount < b.staticCount { - return true - } - if a.staticCount > b.staticCount { - return false - } - // secundary key - if a.paramCount < b.paramCount { - return true - } - if a.paramCount > b.paramCount { - return false - } - return a.route.Path < b.route.Path -} diff --git a/vendor/github.com/emicklei/go-restful/custom_verb.go b/vendor/github.com/emicklei/go-restful/custom_verb.go deleted file mode 100644 index bfc17efde..000000000 --- a/vendor/github.com/emicklei/go-restful/custom_verb.go +++ /dev/null @@ -1,29 +0,0 @@ -package restful - -import ( - "fmt" - "regexp" -) - -var ( - customVerbReg = regexp.MustCompile(":([A-Za-z]+)$") -) - -func hasCustomVerb(routeToken string) bool { - return customVerbReg.MatchString(routeToken) -} - -func isMatchCustomVerb(routeToken string, pathToken string) bool { - rs := customVerbReg.FindStringSubmatch(routeToken) - if len(rs) < 2 { - return false - } - - customVerb := rs[1] - specificVerbReg := regexp.MustCompile(fmt.Sprintf(":%s$", customVerb)) - return specificVerbReg.MatchString(pathToken) -} - -func removeCustomVerb(str string) string { - return customVerbReg.ReplaceAllString(str, "") -} diff --git a/vendor/github.com/emicklei/go-restful/doc.go b/vendor/github.com/emicklei/go-restful/doc.go deleted file mode 100644 index f7c16b01f..000000000 --- a/vendor/github.com/emicklei/go-restful/doc.go +++ /dev/null @@ -1,185 +0,0 @@ -/* -Package restful , a lean package for creating REST-style WebServices without magic. - -WebServices and Routes - -A WebService has a collection of Route objects that dispatch incoming Http Requests to a function calls. -Typically, a WebService has a root path (e.g. /users) and defines common MIME types for its routes. -WebServices must be added to a container (see below) in order to handler Http requests from a server. - -A Route is defined by a HTTP method, an URL path and (optionally) the MIME types it consumes (Content-Type) and produces (Accept). -This package has the logic to find the best matching Route and if found, call its Function. - - ws := new(restful.WebService) - ws. - Path("/users"). - Consumes(restful.MIME_JSON, restful.MIME_XML). - Produces(restful.MIME_JSON, restful.MIME_XML) - - ws.Route(ws.GET("/{user-id}").To(u.findUser)) // u is a UserResource - - ... - - // GET http://localhost:8080/users/1 - func (u UserResource) findUser(request *restful.Request, response *restful.Response) { - id := request.PathParameter("user-id") - ... - } - -The (*Request, *Response) arguments provide functions for reading information from the request and writing information back to the response. - -See the example https://github.com/emicklei/go-restful/blob/master/examples/restful-user-resource.go with a full implementation. - -Regular expression matching Routes - -A Route parameter can be specified using the format "uri/{var[:regexp]}" or the special version "uri/{var:*}" for matching the tail of the path. -For example, /persons/{name:[A-Z][A-Z]} can be used to restrict values for the parameter "name" to only contain capital alphabetic characters. -Regular expressions must use the standard Go syntax as described in the regexp package. (https://code.google.com/p/re2/wiki/Syntax) -This feature requires the use of a CurlyRouter. - -Containers - -A Container holds a collection of WebServices, Filters and a http.ServeMux for multiplexing http requests. -Using the statements "restful.Add(...) and restful.Filter(...)" will register WebServices and Filters to the Default Container. -The Default container of go-restful uses the http.DefaultServeMux. -You can create your own Container and create a new http.Server for that particular container. - - container := restful.NewContainer() - server := &http.Server{Addr: ":8081", Handler: container} - -Filters - -A filter dynamically intercepts requests and responses to transform or use the information contained in the requests or responses. -You can use filters to perform generic logging, measurement, authentication, redirect, set response headers etc. -In the restful package there are three hooks into the request,response flow where filters can be added. -Each filter must define a FilterFunction: - - func (req *restful.Request, resp *restful.Response, chain *restful.FilterChain) - -Use the following statement to pass the request,response pair to the next filter or RouteFunction - - chain.ProcessFilter(req, resp) - -Container Filters - -These are processed before any registered WebService. - - // install a (global) filter for the default container (processed before any webservice) - restful.Filter(globalLogging) - -WebService Filters - -These are processed before any Route of a WebService. - - // install a webservice filter (processed before any route) - ws.Filter(webserviceLogging).Filter(measureTime) - - -Route Filters - -These are processed before calling the function associated with the Route. - - // install 2 chained route filters (processed before calling findUser) - ws.Route(ws.GET("/{user-id}").Filter(routeLogging).Filter(NewCountFilter().routeCounter).To(findUser)) - -See the example https://github.com/emicklei/go-restful/blob/master/examples/restful-filters.go with full implementations. - -Response Encoding - -Two encodings are supported: gzip and deflate. To enable this for all responses: - - restful.DefaultContainer.EnableContentEncoding(true) - -If a Http request includes the Accept-Encoding header then the response content will be compressed using the specified encoding. -Alternatively, you can create a Filter that performs the encoding and install it per WebService or Route. - -See the example https://github.com/emicklei/go-restful/blob/master/examples/restful-encoding-filter.go - -OPTIONS support - -By installing a pre-defined container filter, your Webservice(s) can respond to the OPTIONS Http request. - - Filter(OPTIONSFilter()) - -CORS - -By installing the filter of a CrossOriginResourceSharing (CORS), your WebService(s) can handle CORS requests. - - cors := CrossOriginResourceSharing{ExposeHeaders: []string{"X-My-Header"}, CookiesAllowed: false, Container: DefaultContainer} - Filter(cors.Filter) - -Error Handling - -Unexpected things happen. If a request cannot be processed because of a failure, your service needs to tell via the response what happened and why. -For this reason HTTP status codes exist and it is important to use the correct code in every exceptional situation. - - 400: Bad Request - -If path or query parameters are not valid (content or type) then use http.StatusBadRequest. - - 404: Not Found - -Despite a valid URI, the resource requested may not be available - - 500: Internal Server Error - -If the application logic could not process the request (or write the response) then use http.StatusInternalServerError. - - 405: Method Not Allowed - -The request has a valid URL but the method (GET,PUT,POST,...) is not allowed. - - 406: Not Acceptable - -The request does not have or has an unknown Accept Header set for this operation. - - 415: Unsupported Media Type - -The request does not have or has an unknown Content-Type Header set for this operation. - -ServiceError - -In addition to setting the correct (error) Http status code, you can choose to write a ServiceError message on the response. - -Performance options - -This package has several options that affect the performance of your service. It is important to understand them and how you can change it. - - restful.DefaultContainer.DoNotRecover(false) - -DoNotRecover controls whether panics will be caught to return HTTP 500. -If set to false, the container will recover from panics. -Default value is true - - restful.SetCompressorProvider(NewBoundedCachedCompressors(20, 20)) - -If content encoding is enabled then the default strategy for getting new gzip/zlib writers and readers is to use a sync.Pool. -Because writers are expensive structures, performance is even more improved when using a preloaded cache. You can also inject your own implementation. - -Trouble shooting - -This package has the means to produce detail logging of the complete Http request matching process and filter invocation. -Enabling this feature requires you to set an implementation of restful.StdLogger (e.g. log.Logger) instance such as: - - restful.TraceLogger(log.New(os.Stdout, "[restful] ", log.LstdFlags|log.Lshortfile)) - -Logging - -The restful.SetLogger() method allows you to override the logger used by the package. By default restful -uses the standard library `log` package and logs to stdout. Different logging packages are supported as -long as they conform to `StdLogger` interface defined in the `log` sub-package, writing an adapter for your -preferred package is simple. - -Resources - -[project]: https://github.com/emicklei/go-restful - -[examples]: https://github.com/emicklei/go-restful/blob/master/examples - -[design]: http://ernestmicklei.com/2012/11/11/go-restful-api-design/ - -[showcases]: https://github.com/emicklei/mora, https://github.com/emicklei/landskape - -(c) 2012-2015, http://ernestmicklei.com. MIT License -*/ -package restful diff --git a/vendor/github.com/emicklei/go-restful/entity_accessors.go b/vendor/github.com/emicklei/go-restful/entity_accessors.go deleted file mode 100644 index 66dfc824f..000000000 --- a/vendor/github.com/emicklei/go-restful/entity_accessors.go +++ /dev/null @@ -1,162 +0,0 @@ -package restful - -// Copyright 2015 Ernest Micklei. All rights reserved. -// Use of this source code is governed by a license -// that can be found in the LICENSE file. - -import ( - "encoding/xml" - "strings" - "sync" -) - -// EntityReaderWriter can read and write values using an encoding such as JSON,XML. -type EntityReaderWriter interface { - // Read a serialized version of the value from the request. - // The Request may have a decompressing reader. Depends on Content-Encoding. - Read(req *Request, v interface{}) error - - // Write a serialized version of the value on the response. - // The Response may have a compressing writer. Depends on Accept-Encoding. - // status should be a valid Http Status code - Write(resp *Response, status int, v interface{}) error -} - -// entityAccessRegistry is a singleton -var entityAccessRegistry = &entityReaderWriters{ - protection: new(sync.RWMutex), - accessors: map[string]EntityReaderWriter{}, -} - -// entityReaderWriters associates MIME to an EntityReaderWriter -type entityReaderWriters struct { - protection *sync.RWMutex - accessors map[string]EntityReaderWriter -} - -func init() { - RegisterEntityAccessor(MIME_JSON, NewEntityAccessorJSON(MIME_JSON)) - RegisterEntityAccessor(MIME_XML, NewEntityAccessorXML(MIME_XML)) -} - -// RegisterEntityAccessor add/overrides the ReaderWriter for encoding content with this MIME type. -func RegisterEntityAccessor(mime string, erw EntityReaderWriter) { - entityAccessRegistry.protection.Lock() - defer entityAccessRegistry.protection.Unlock() - entityAccessRegistry.accessors[mime] = erw -} - -// NewEntityAccessorJSON returns a new EntityReaderWriter for accessing JSON content. -// This package is already initialized with such an accessor using the MIME_JSON contentType. -func NewEntityAccessorJSON(contentType string) EntityReaderWriter { - return entityJSONAccess{ContentType: contentType} -} - -// NewEntityAccessorXML returns a new EntityReaderWriter for accessing XML content. -// This package is already initialized with such an accessor using the MIME_XML contentType. -func NewEntityAccessorXML(contentType string) EntityReaderWriter { - return entityXMLAccess{ContentType: contentType} -} - -// accessorAt returns the registered ReaderWriter for this MIME type. -func (r *entityReaderWriters) accessorAt(mime string) (EntityReaderWriter, bool) { - r.protection.RLock() - defer r.protection.RUnlock() - er, ok := r.accessors[mime] - if !ok { - // retry with reverse lookup - // more expensive but we are in an exceptional situation anyway - for k, v := range r.accessors { - if strings.Contains(mime, k) { - return v, true - } - } - } - return er, ok -} - -// entityXMLAccess is a EntityReaderWriter for XML encoding -type entityXMLAccess struct { - // This is used for setting the Content-Type header when writing - ContentType string -} - -// Read unmarshalls the value from XML -func (e entityXMLAccess) Read(req *Request, v interface{}) error { - return xml.NewDecoder(req.Request.Body).Decode(v) -} - -// Write marshalls the value to JSON and set the Content-Type Header. -func (e entityXMLAccess) Write(resp *Response, status int, v interface{}) error { - return writeXML(resp, status, e.ContentType, v) -} - -// writeXML marshalls the value to JSON and set the Content-Type Header. -func writeXML(resp *Response, status int, contentType string, v interface{}) error { - if v == nil { - resp.WriteHeader(status) - // do not write a nil representation - return nil - } - if resp.prettyPrint { - // pretty output must be created and written explicitly - output, err := xml.MarshalIndent(v, " ", " ") - if err != nil { - return err - } - resp.Header().Set(HEADER_ContentType, contentType) - resp.WriteHeader(status) - _, err = resp.Write([]byte(xml.Header)) - if err != nil { - return err - } - _, err = resp.Write(output) - return err - } - // not-so-pretty - resp.Header().Set(HEADER_ContentType, contentType) - resp.WriteHeader(status) - return xml.NewEncoder(resp).Encode(v) -} - -// entityJSONAccess is a EntityReaderWriter for JSON encoding -type entityJSONAccess struct { - // This is used for setting the Content-Type header when writing - ContentType string -} - -// Read unmarshalls the value from JSON -func (e entityJSONAccess) Read(req *Request, v interface{}) error { - decoder := NewDecoder(req.Request.Body) - decoder.UseNumber() - return decoder.Decode(v) -} - -// Write marshalls the value to JSON and set the Content-Type Header. -func (e entityJSONAccess) Write(resp *Response, status int, v interface{}) error { - return writeJSON(resp, status, e.ContentType, v) -} - -// write marshalls the value to JSON and set the Content-Type Header. -func writeJSON(resp *Response, status int, contentType string, v interface{}) error { - if v == nil { - resp.WriteHeader(status) - // do not write a nil representation - return nil - } - if resp.prettyPrint { - // pretty output must be created and written explicitly - output, err := MarshalIndent(v, "", " ") - if err != nil { - return err - } - resp.Header().Set(HEADER_ContentType, contentType) - resp.WriteHeader(status) - _, err = resp.Write(output) - return err - } - // not-so-pretty - resp.Header().Set(HEADER_ContentType, contentType) - resp.WriteHeader(status) - return NewEncoder(resp).Encode(v) -} diff --git a/vendor/github.com/emicklei/go-restful/filter.go b/vendor/github.com/emicklei/go-restful/filter.go deleted file mode 100644 index c23bfb591..000000000 --- a/vendor/github.com/emicklei/go-restful/filter.go +++ /dev/null @@ -1,35 +0,0 @@ -package restful - -// Copyright 2013 Ernest Micklei. All rights reserved. -// Use of this source code is governed by a license -// that can be found in the LICENSE file. - -// FilterChain is a request scoped object to process one or more filters before calling the target RouteFunction. -type FilterChain struct { - Filters []FilterFunction // ordered list of FilterFunction - Index int // index into filters that is currently in progress - Target RouteFunction // function to call after passing all filters -} - -// ProcessFilter passes the request,response pair through the next of Filters. -// Each filter can decide to proceed to the next Filter or handle the Response itself. -func (f *FilterChain) ProcessFilter(request *Request, response *Response) { - if f.Index < len(f.Filters) { - f.Index++ - f.Filters[f.Index-1](request, response, f) - } else { - f.Target(request, response) - } -} - -// FilterFunction definitions must call ProcessFilter on the FilterChain to pass on the control and eventually call the RouteFunction -type FilterFunction func(*Request, *Response, *FilterChain) - -// NoBrowserCacheFilter is a filter function to set HTTP headers that disable browser caching -// See examples/restful-no-cache-filter.go for usage -func NoBrowserCacheFilter(req *Request, resp *Response, chain *FilterChain) { - resp.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") // HTTP 1.1. - resp.Header().Set("Pragma", "no-cache") // HTTP 1.0. - resp.Header().Set("Expires", "0") // Proxies. - chain.ProcessFilter(req, resp) -} diff --git a/vendor/github.com/emicklei/go-restful/json.go b/vendor/github.com/emicklei/go-restful/json.go deleted file mode 100644 index 871165166..000000000 --- a/vendor/github.com/emicklei/go-restful/json.go +++ /dev/null @@ -1,11 +0,0 @@ -// +build !jsoniter - -package restful - -import "encoding/json" - -var ( - MarshalIndent = json.MarshalIndent - NewDecoder = json.NewDecoder - NewEncoder = json.NewEncoder -) diff --git a/vendor/github.com/emicklei/go-restful/jsoniter.go b/vendor/github.com/emicklei/go-restful/jsoniter.go deleted file mode 100644 index 11b8f8ae7..000000000 --- a/vendor/github.com/emicklei/go-restful/jsoniter.go +++ /dev/null @@ -1,12 +0,0 @@ -// +build jsoniter - -package restful - -import "github.com/json-iterator/go" - -var ( - json = jsoniter.ConfigCompatibleWithStandardLibrary - MarshalIndent = json.MarshalIndent - NewDecoder = json.NewDecoder - NewEncoder = json.NewEncoder -) diff --git a/vendor/github.com/emicklei/go-restful/jsr311.go b/vendor/github.com/emicklei/go-restful/jsr311.go deleted file mode 100644 index 9cfd59a1c..000000000 --- a/vendor/github.com/emicklei/go-restful/jsr311.go +++ /dev/null @@ -1,316 +0,0 @@ -package restful - -// Copyright 2013 Ernest Micklei. All rights reserved. -// Use of this source code is governed by a license -// that can be found in the LICENSE file. - -import ( - "errors" - "fmt" - "net/http" - "sort" - "strings" -) - -// RouterJSR311 implements the flow for matching Requests to Routes (and consequently Resource Functions) -// as specified by the JSR311 http://jsr311.java.net/nonav/releases/1.1/spec/spec.html. -// RouterJSR311 implements the Router interface. -// Concept of locators is not implemented. -type RouterJSR311 struct{} - -// SelectRoute is part of the Router interface and returns the best match -// for the WebService and its Route for the given Request. -func (r RouterJSR311) SelectRoute( - webServices []*WebService, - httpRequest *http.Request) (selectedService *WebService, selectedRoute *Route, err error) { - - // Identify the root resource class (WebService) - dispatcher, finalMatch, err := r.detectDispatcher(httpRequest.URL.Path, webServices) - if err != nil { - return nil, nil, NewError(http.StatusNotFound, "") - } - // Obtain the set of candidate methods (Routes) - routes := r.selectRoutes(dispatcher, finalMatch) - if len(routes) == 0 { - return dispatcher, nil, NewError(http.StatusNotFound, "404: Page Not Found") - } - - // Identify the method (Route) that will handle the request - route, ok := r.detectRoute(routes, httpRequest) - return dispatcher, route, ok -} - -// ExtractParameters is used to obtain the path parameters from the route using the same matching -// engine as the JSR 311 router. -func (r RouterJSR311) ExtractParameters(route *Route, webService *WebService, urlPath string) map[string]string { - webServiceExpr := webService.pathExpr - webServiceMatches := webServiceExpr.Matcher.FindStringSubmatch(urlPath) - pathParameters := r.extractParams(webServiceExpr, webServiceMatches) - routeExpr := route.pathExpr - routeMatches := routeExpr.Matcher.FindStringSubmatch(webServiceMatches[len(webServiceMatches)-1]) - routeParams := r.extractParams(routeExpr, routeMatches) - for key, value := range routeParams { - pathParameters[key] = value - } - return pathParameters -} - -func (RouterJSR311) extractParams(pathExpr *pathExpression, matches []string) map[string]string { - params := map[string]string{} - for i := 1; i < len(matches); i++ { - if len(pathExpr.VarNames) >= i { - params[pathExpr.VarNames[i-1]] = matches[i] - } - } - return params -} - -// http://jsr311.java.net/nonav/releases/1.1/spec/spec3.html#x3-360003.7.2 -func (r RouterJSR311) detectRoute(routes []Route, httpRequest *http.Request) (*Route, error) { - candidates := make([]*Route, 0, 8) - for i, each := range routes { - ok := true - for _, fn := range each.If { - if !fn(httpRequest) { - ok = false - break - } - } - if ok { - candidates = append(candidates, &routes[i]) - } - } - if len(candidates) == 0 { - if trace { - traceLogger.Printf("no Route found (from %d) that passes conditional checks", len(routes)) - } - return nil, NewError(http.StatusNotFound, "404: Not Found") - } - - // http method - previous := candidates - candidates = candidates[:0] - for _, each := range previous { - if httpRequest.Method == each.Method { - candidates = append(candidates, each) - } - } - if len(candidates) == 0 { - if trace { - traceLogger.Printf("no Route found (in %d routes) that matches HTTP method %s\n", len(previous), httpRequest.Method) - } - allowed := []string{} - allowedLoop: - for _, candidate := range previous { - for _, method := range allowed { - if method == candidate.Method { - continue allowedLoop - } - } - allowed = append(allowed, candidate.Method) - } - header := http.Header{"Allow": []string{strings.Join(allowed, ", ")}} - return nil, NewErrorWithHeader(http.StatusMethodNotAllowed, "405: Method Not Allowed", header) - } - - // content-type - contentType := httpRequest.Header.Get(HEADER_ContentType) - previous = candidates - candidates = candidates[:0] - for _, each := range previous { - if each.matchesContentType(contentType) { - candidates = append(candidates, each) - } - } - if len(candidates) == 0 { - if trace { - traceLogger.Printf("no Route found (from %d) that matches HTTP Content-Type: %s\n", len(previous), contentType) - } - if httpRequest.ContentLength > 0 { - return nil, NewError(http.StatusUnsupportedMediaType, "415: Unsupported Media Type") - } - } - - // accept - previous = candidates - candidates = candidates[:0] - accept := httpRequest.Header.Get(HEADER_Accept) - if len(accept) == 0 { - accept = "*/*" - } - for _, each := range previous { - if each.matchesAccept(accept) { - candidates = append(candidates, each) - } - } - if len(candidates) == 0 { - if trace { - traceLogger.Printf("no Route found (from %d) that matches HTTP Accept: %s\n", len(previous), accept) - } - available := []string{} - for _, candidate := range previous { - available = append(available, candidate.Produces...) - } - return nil, NewError( - http.StatusNotAcceptable, - fmt.Sprintf("406: Not Acceptable\n\nAvailable representations: %s", strings.Join(available, ", ")), - ) - } - // return r.bestMatchByMedia(outputMediaOk, contentType, accept), nil - return candidates[0], nil -} - -// http://jsr311.java.net/nonav/releases/1.1/spec/spec3.html#x3-360003.7.2 -// n/m > n/* > */* -func (r RouterJSR311) bestMatchByMedia(routes []Route, contentType string, accept string) *Route { - // TODO - return &routes[0] -} - -// http://jsr311.java.net/nonav/releases/1.1/spec/spec3.html#x3-360003.7.2 (step 2) -func (r RouterJSR311) selectRoutes(dispatcher *WebService, pathRemainder string) []Route { - filtered := &sortableRouteCandidates{} - for _, each := range dispatcher.Routes() { - pathExpr := each.pathExpr - matches := pathExpr.Matcher.FindStringSubmatch(pathRemainder) - if matches != nil { - lastMatch := matches[len(matches)-1] - if len(lastMatch) == 0 || lastMatch == "/" { // do not include if value is neither empty nor ‘/’. - filtered.candidates = append(filtered.candidates, - routeCandidate{each, len(matches) - 1, pathExpr.LiteralCount, pathExpr.VarCount}) - } - } - } - if len(filtered.candidates) == 0 { - if trace { - traceLogger.Printf("WebService on path %s has no routes that match URL path remainder:%s\n", dispatcher.rootPath, pathRemainder) - } - return []Route{} - } - sort.Sort(sort.Reverse(filtered)) - - // select other routes from candidates whoes expression matches rmatch - matchingRoutes := []Route{filtered.candidates[0].route} - for c := 1; c < len(filtered.candidates); c++ { - each := filtered.candidates[c] - if each.route.pathExpr.Matcher.MatchString(pathRemainder) { - matchingRoutes = append(matchingRoutes, each.route) - } - } - return matchingRoutes -} - -// http://jsr311.java.net/nonav/releases/1.1/spec/spec3.html#x3-360003.7.2 (step 1) -func (r RouterJSR311) detectDispatcher(requestPath string, dispatchers []*WebService) (*WebService, string, error) { - filtered := &sortableDispatcherCandidates{} - for _, each := range dispatchers { - matches := each.pathExpr.Matcher.FindStringSubmatch(requestPath) - if matches != nil { - filtered.candidates = append(filtered.candidates, - dispatcherCandidate{each, matches[len(matches)-1], len(matches), each.pathExpr.LiteralCount, each.pathExpr.VarCount}) - } - } - if len(filtered.candidates) == 0 { - if trace { - traceLogger.Printf("no WebService was found to match URL path:%s\n", requestPath) - } - return nil, "", errors.New("not found") - } - sort.Sort(sort.Reverse(filtered)) - return filtered.candidates[0].dispatcher, filtered.candidates[0].finalMatch, nil -} - -// Types and functions to support the sorting of Routes - -type routeCandidate struct { - route Route - matchesCount int // the number of capturing groups - literalCount int // the number of literal characters (means those not resulting from template variable substitution) - nonDefaultCount int // the number of capturing groups with non-default regular expressions (i.e. not ‘([^ /]+?)’) -} - -func (r routeCandidate) expressionToMatch() string { - return r.route.pathExpr.Source -} - -func (r routeCandidate) String() string { - return fmt.Sprintf("(m=%d,l=%d,n=%d)", r.matchesCount, r.literalCount, r.nonDefaultCount) -} - -type sortableRouteCandidates struct { - candidates []routeCandidate -} - -func (rcs *sortableRouteCandidates) Len() int { - return len(rcs.candidates) -} -func (rcs *sortableRouteCandidates) Swap(i, j int) { - rcs.candidates[i], rcs.candidates[j] = rcs.candidates[j], rcs.candidates[i] -} -func (rcs *sortableRouteCandidates) Less(i, j int) bool { - ci := rcs.candidates[i] - cj := rcs.candidates[j] - // primary key - if ci.literalCount < cj.literalCount { - return true - } - if ci.literalCount > cj.literalCount { - return false - } - // secundary key - if ci.matchesCount < cj.matchesCount { - return true - } - if ci.matchesCount > cj.matchesCount { - return false - } - // tertiary key - if ci.nonDefaultCount < cj.nonDefaultCount { - return true - } - if ci.nonDefaultCount > cj.nonDefaultCount { - return false - } - // quaternary key ("source" is interpreted as Path) - return ci.route.Path < cj.route.Path -} - -// Types and functions to support the sorting of Dispatchers - -type dispatcherCandidate struct { - dispatcher *WebService - finalMatch string - matchesCount int // the number of capturing groups - literalCount int // the number of literal characters (means those not resulting from template variable substitution) - nonDefaultCount int // the number of capturing groups with non-default regular expressions (i.e. not ‘([^ /]+?)’) -} -type sortableDispatcherCandidates struct { - candidates []dispatcherCandidate -} - -func (dc *sortableDispatcherCandidates) Len() int { - return len(dc.candidates) -} -func (dc *sortableDispatcherCandidates) Swap(i, j int) { - dc.candidates[i], dc.candidates[j] = dc.candidates[j], dc.candidates[i] -} -func (dc *sortableDispatcherCandidates) Less(i, j int) bool { - ci := dc.candidates[i] - cj := dc.candidates[j] - // primary key - if ci.matchesCount < cj.matchesCount { - return true - } - if ci.matchesCount > cj.matchesCount { - return false - } - // secundary key - if ci.literalCount < cj.literalCount { - return true - } - if ci.literalCount > cj.literalCount { - return false - } - // tertiary key - return ci.nonDefaultCount < cj.nonDefaultCount -} diff --git a/vendor/github.com/emicklei/go-restful/log/log.go b/vendor/github.com/emicklei/go-restful/log/log.go deleted file mode 100644 index 6cd44c7a5..000000000 --- a/vendor/github.com/emicklei/go-restful/log/log.go +++ /dev/null @@ -1,34 +0,0 @@ -package log - -import ( - stdlog "log" - "os" -) - -// StdLogger corresponds to a minimal subset of the interface satisfied by stdlib log.Logger -type StdLogger interface { - Print(v ...interface{}) - Printf(format string, v ...interface{}) -} - -var Logger StdLogger - -func init() { - // default Logger - SetLogger(stdlog.New(os.Stderr, "[restful] ", stdlog.LstdFlags|stdlog.Lshortfile)) -} - -// SetLogger sets the logger for this package -func SetLogger(customLogger StdLogger) { - Logger = customLogger -} - -// Print delegates to the Logger -func Print(v ...interface{}) { - Logger.Print(v...) -} - -// Printf delegates to the Logger -func Printf(format string, v ...interface{}) { - Logger.Printf(format, v...) -} diff --git a/vendor/github.com/emicklei/go-restful/logger.go b/vendor/github.com/emicklei/go-restful/logger.go deleted file mode 100644 index 6595df002..000000000 --- a/vendor/github.com/emicklei/go-restful/logger.go +++ /dev/null @@ -1,32 +0,0 @@ -package restful - -// Copyright 2014 Ernest Micklei. All rights reserved. -// Use of this source code is governed by a license -// that can be found in the LICENSE file. -import ( - "github.com/emicklei/go-restful/log" -) - -var trace bool = false -var traceLogger log.StdLogger - -func init() { - traceLogger = log.Logger // use the package logger by default -} - -// TraceLogger enables detailed logging of Http request matching and filter invocation. Default no logger is set. -// You may call EnableTracing() directly to enable trace logging to the package-wide logger. -func TraceLogger(logger log.StdLogger) { - traceLogger = logger - EnableTracing(logger != nil) -} - -// SetLogger exposes the setter for the global logger on the top-level package -func SetLogger(customLogger log.StdLogger) { - log.SetLogger(customLogger) -} - -// EnableTracing can be used to Trace logging on and off. -func EnableTracing(enabled bool) { - trace = enabled -} diff --git a/vendor/github.com/emicklei/go-restful/mime.go b/vendor/github.com/emicklei/go-restful/mime.go deleted file mode 100644 index 33014471b..000000000 --- a/vendor/github.com/emicklei/go-restful/mime.go +++ /dev/null @@ -1,50 +0,0 @@ -package restful - -import ( - "strconv" - "strings" -) - -type mime struct { - media string - quality float64 -} - -// insertMime adds a mime to a list and keeps it sorted by quality. -func insertMime(l []mime, e mime) []mime { - for i, each := range l { - // if current mime has lower quality then insert before - if e.quality > each.quality { - left := append([]mime{}, l[0:i]...) - return append(append(left, e), l[i:]...) - } - } - return append(l, e) -} - -const qFactorWeightingKey = "q" - -// sortedMimes returns a list of mime sorted (desc) by its specified quality. -// e.g. text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3 -func sortedMimes(accept string) (sorted []mime) { - for _, each := range strings.Split(accept, ",") { - typeAndQuality := strings.Split(strings.Trim(each, " "), ";") - if len(typeAndQuality) == 1 { - sorted = insertMime(sorted, mime{typeAndQuality[0], 1.0}) - } else { - // take factor - qAndWeight := strings.Split(typeAndQuality[1], "=") - if len(qAndWeight) == 2 && strings.Trim(qAndWeight[0], " ") == qFactorWeightingKey { - f, err := strconv.ParseFloat(qAndWeight[1], 64) - if err != nil { - traceLogger.Printf("unable to parse quality in %s, %v", each, err) - } else { - sorted = insertMime(sorted, mime{typeAndQuality[0], f}) - } - } else { - sorted = insertMime(sorted, mime{typeAndQuality[0], 1.0}) - } - } - } - return -} diff --git a/vendor/github.com/emicklei/go-restful/options_filter.go b/vendor/github.com/emicklei/go-restful/options_filter.go deleted file mode 100644 index 5c1b34251..000000000 --- a/vendor/github.com/emicklei/go-restful/options_filter.go +++ /dev/null @@ -1,34 +0,0 @@ -package restful - -import "strings" - -// Copyright 2013 Ernest Micklei. All rights reserved. -// Use of this source code is governed by a license -// that can be found in the LICENSE file. - -// OPTIONSFilter is a filter function that inspects the Http Request for the OPTIONS method -// and provides the response with a set of allowed methods for the request URL Path. -// As for any filter, you can also install it for a particular WebService within a Container. -// Note: this filter is not needed when using CrossOriginResourceSharing (for CORS). -func (c *Container) OPTIONSFilter(req *Request, resp *Response, chain *FilterChain) { - if "OPTIONS" != req.Request.Method { - chain.ProcessFilter(req, resp) - return - } - - archs := req.Request.Header.Get(HEADER_AccessControlRequestHeaders) - methods := strings.Join(c.computeAllowedMethods(req), ",") - origin := req.Request.Header.Get(HEADER_Origin) - - resp.AddHeader(HEADER_Allow, methods) - resp.AddHeader(HEADER_AccessControlAllowOrigin, origin) - resp.AddHeader(HEADER_AccessControlAllowHeaders, archs) - resp.AddHeader(HEADER_AccessControlAllowMethods, methods) -} - -// OPTIONSFilter is a filter function that inspects the Http Request for the OPTIONS method -// and provides the response with a set of allowed methods for the request URL Path. -// Note: this filter is not needed when using CrossOriginResourceSharing (for CORS). -func OPTIONSFilter() FilterFunction { - return DefaultContainer.OPTIONSFilter -} diff --git a/vendor/github.com/emicklei/go-restful/parameter.go b/vendor/github.com/emicklei/go-restful/parameter.go deleted file mode 100644 index febe2cc17..000000000 --- a/vendor/github.com/emicklei/go-restful/parameter.go +++ /dev/null @@ -1,151 +0,0 @@ -package restful - -// Copyright 2013 Ernest Micklei. All rights reserved. -// Use of this source code is governed by a license -// that can be found in the LICENSE file. - -const ( - // PathParameterKind = indicator of Request parameter type "path" - PathParameterKind = iota - - // QueryParameterKind = indicator of Request parameter type "query" - QueryParameterKind - - // BodyParameterKind = indicator of Request parameter type "body" - BodyParameterKind - - // HeaderParameterKind = indicator of Request parameter type "header" - HeaderParameterKind - - // 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") - - // CollectionFormatSSV space separated values `foo bar` - CollectionFormatSSV = CollectionFormat("ssv") - - // CollectionFormatTSV tab separated values `foo\tbar` - CollectionFormatTSV = CollectionFormat("tsv") - - // CollectionFormatPipes pipe separated values `foo|bar` - CollectionFormatPipes = CollectionFormat("pipes") - - // CollectionFormatMulti corresponds to multiple parameter instances instead of multiple values for a single - // instance `foo=bar&foo=baz`. This is valid only for QueryParameters and FormParameters - CollectionFormatMulti = CollectionFormat("multi") -) - -type CollectionFormat string - -func (cf CollectionFormat) String() string { - return string(cf) -} - -// Parameter is for documententing the parameter used in a Http Request -// ParameterData kinds are Path,Query and Body -type Parameter struct { - data *ParameterData -} - -// ParameterData represents the state of a Parameter. -// It is made public to make it accessible to e.g. the Swagger package. -type ParameterData struct { - Name, Description, DataType, DataFormat string - Kind int - Required bool - AllowableValues map[string]string - AllowMultiple bool - DefaultValue string - CollectionFormat string -} - -// Data returns the state of the Parameter -func (p *Parameter) Data() ParameterData { - return *p.data -} - -// Kind returns the parameter type indicator (see const for valid values) -func (p *Parameter) Kind() int { - return p.data.Kind -} - -func (p *Parameter) bePath() *Parameter { - p.data.Kind = PathParameterKind - return p -} -func (p *Parameter) beQuery() *Parameter { - p.data.Kind = QueryParameterKind - return p -} -func (p *Parameter) beBody() *Parameter { - p.data.Kind = BodyParameterKind - return p -} - -func (p *Parameter) beHeader() *Parameter { - p.data.Kind = HeaderParameterKind - return p -} - -func (p *Parameter) beForm() *Parameter { - p.data.Kind = FormParameterKind - 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 - return p -} - -// AllowMultiple sets the allowMultiple field and returns the receiver -func (p *Parameter) AllowMultiple(multiple bool) *Parameter { - p.data.AllowMultiple = multiple - return p -} - -// AllowableValues sets the allowableValues field and returns the receiver -func (p *Parameter) AllowableValues(values map[string]string) *Parameter { - p.data.AllowableValues = values - return p -} - -// DataType sets the dataType field and returns the receiver -func (p *Parameter) DataType(typeName string) *Parameter { - p.data.DataType = typeName - return p -} - -// DataFormat sets the dataFormat field for Swagger UI -func (p *Parameter) DataFormat(formatName string) *Parameter { - p.data.DataFormat = formatName - return p -} - -// DefaultValue sets the default value field and returns the receiver -func (p *Parameter) DefaultValue(stringRepresentation string) *Parameter { - p.data.DefaultValue = stringRepresentation - return p -} - -// Description sets the description value field and returns the receiver -func (p *Parameter) Description(doc string) *Parameter { - p.data.Description = doc - return p -} - -// CollectionFormat sets the collection format for an array type -func (p *Parameter) CollectionFormat(format CollectionFormat) *Parameter { - p.data.CollectionFormat = format.String() - return p -} diff --git a/vendor/github.com/emicklei/go-restful/path_expression.go b/vendor/github.com/emicklei/go-restful/path_expression.go deleted file mode 100644 index 95a9a2545..000000000 --- a/vendor/github.com/emicklei/go-restful/path_expression.go +++ /dev/null @@ -1,74 +0,0 @@ -package restful - -// Copyright 2013 Ernest Micklei. All rights reserved. -// Use of this source code is governed by a license -// that can be found in the LICENSE file. - -import ( - "bytes" - "fmt" - "regexp" - "strings" -) - -// PathExpression holds a compiled path expression (RegExp) needed to match against -// Http request paths and to extract path parameter values. -type pathExpression struct { - LiteralCount int // the number of literal characters (means those not resulting from template variable substitution) - VarNames []string // the names of parameters (enclosed by {}) in the path - VarCount int // the number of named parameters (enclosed by {}) in the path - Matcher *regexp.Regexp - Source string // Path as defined by the RouteBuilder - tokens []string -} - -// NewPathExpression creates a PathExpression from the input URL path. -// Returns an error if the path is invalid. -func newPathExpression(path string) (*pathExpression, error) { - expression, literalCount, varNames, varCount, tokens := templateToRegularExpression(path) - compiled, err := regexp.Compile(expression) - if err != nil { - return nil, err - } - return &pathExpression{literalCount, varNames, varCount, compiled, expression, tokens}, nil -} - -// http://jsr311.java.net/nonav/releases/1.1/spec/spec3.html#x3-370003.7.3 -func templateToRegularExpression(template string) (expression string, literalCount int, varNames []string, varCount int, tokens []string) { - var buffer bytes.Buffer - buffer.WriteString("^") - //tokens = strings.Split(template, "/") - tokens = tokenizePath(template) - for _, each := range tokens { - if each == "" { - continue - } - buffer.WriteString("/") - if strings.HasPrefix(each, "{") { - // check for regular expression in variable - colon := strings.Index(each, ":") - var varName string - if colon != -1 { - // extract expression - varName = strings.TrimSpace(each[1:colon]) - paramExpr := strings.TrimSpace(each[colon+1 : len(each)-1]) - if paramExpr == "*" { // special case - buffer.WriteString("(.*)") - } else { - buffer.WriteString(fmt.Sprintf("(%s)", paramExpr)) // between colon and closing moustache - } - } else { - // plain var - varName = strings.TrimSpace(each[1 : len(each)-1]) - buffer.WriteString("([^/]+?)") - } - varNames = append(varNames, varName) - varCount += 1 - } else { - literalCount += len(each) - encoded := each // TODO URI encode - buffer.WriteString(regexp.QuoteMeta(encoded)) - } - } - return strings.TrimRight(buffer.String(), "/") + "(/.*)?$", literalCount, varNames, varCount, tokens -} diff --git a/vendor/github.com/emicklei/go-restful/path_processor.go b/vendor/github.com/emicklei/go-restful/path_processor.go deleted file mode 100644 index 141573245..000000000 --- a/vendor/github.com/emicklei/go-restful/path_processor.go +++ /dev/null @@ -1,74 +0,0 @@ -package restful - -import ( - "bytes" - "strings" -) - -// Copyright 2018 Ernest Micklei. All rights reserved. -// Use of this source code is governed by a license -// that can be found in the LICENSE file. - -// PathProcessor is extra behaviour that a Router can provide to extract path parameters from the path. -// If a Router does not implement this interface then the default behaviour will be used. -type PathProcessor interface { - // ExtractParameters gets the path parameters defined in the route and webService from the urlPath - ExtractParameters(route *Route, webService *WebService, urlPath string) map[string]string -} - -type defaultPathProcessor struct{} - -// Extract the parameters from the request url path -func (d defaultPathProcessor) ExtractParameters(r *Route, _ *WebService, urlPath string) map[string]string { - urlParts := tokenizePath(urlPath) - pathParameters := map[string]string{} - for i, key := range r.pathParts { - var value string - if i >= len(urlParts) { - value = "" - } else { - value = urlParts[i] - } - if r.hasCustomVerb && hasCustomVerb(key) { - key = removeCustomVerb(key) - value = removeCustomVerb(value) - } - - if strings.Index(key, "{") > -1 { // path-parameter - if colon := strings.Index(key, ":"); colon != -1 { - // extract by regex - regPart := key[colon+1 : len(key)-1] - keyPart := key[1:colon] - if regPart == "*" { - pathParameters[keyPart] = untokenizePath(i, urlParts) - break - } else { - pathParameters[keyPart] = value - } - } else { - // without enclosing {} - startIndex := strings.Index(key, "{") - endKeyIndex := strings.Index(key, "}") - - suffixLength := len(key) - endKeyIndex - 1 - endValueIndex := len(value) - suffixLength - - pathParameters[key[startIndex+1:endKeyIndex]] = value[startIndex:endValueIndex] - } - } - } - return pathParameters -} - -// Untokenize back into an URL path using the slash separator -func untokenizePath(offset int, parts []string) string { - var buffer bytes.Buffer - for p := offset; p < len(parts); p++ { - buffer.WriteString(parts[p]) - // do not end - if p < len(parts)-1 { - buffer.WriteString("/") - } - } - return buffer.String() -} diff --git a/vendor/github.com/emicklei/go-restful/request.go b/vendor/github.com/emicklei/go-restful/request.go deleted file mode 100644 index 05d768117..000000000 --- a/vendor/github.com/emicklei/go-restful/request.go +++ /dev/null @@ -1,124 +0,0 @@ -package restful - -// Copyright 2013 Ernest Micklei. All rights reserved. -// Use of this source code is governed by a license -// that can be found in the LICENSE file. - -import ( - "compress/zlib" - "net/http" -) - -var defaultRequestContentType string - -// Request is a wrapper for a http Request that provides convenience methods -type Request struct { - Request *http.Request - 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 { - return &Request{ - Request: httpRequest, - pathParameters: map[string]string{}, - attributes: map[string]interface{}{}, - } // empty parameters, attributes -} - -// If ContentType is missing or */* is given then fall back to this type, otherwise -// a "Unable to unmarshal content of type:" response is returned. -// Valid values are restful.MIME_JSON and restful.MIME_XML -// Example: -// restful.DefaultRequestContentType(restful.MIME_JSON) -func DefaultRequestContentType(mime string) { - defaultRequestContentType = mime -} - -// PathParameter accesses the Path parameter value by its name -func (r *Request) PathParameter(name string) string { - return r.pathParameters[name] -} - -// PathParameters accesses the Path parameter values -func (r *Request) PathParameters() map[string]string { - return r.pathParameters -} - -// QueryParameter returns the (first) Query parameter value by its name -func (r *Request) QueryParameter(name string) string { - return r.Request.FormValue(name) -} - -// QueryParameters returns the all the query parameters values by name -func (r *Request) QueryParameters(name string) []string { - return r.Request.URL.Query()[name] -} - -// BodyParameter parses the body of the request (once for typically a POST or a PUT) and returns the value of the given name or an error. -func (r *Request) BodyParameter(name string) (string, error) { - err := r.Request.ParseForm() - if err != nil { - return "", err - } - return r.Request.PostFormValue(name), nil -} - -// HeaderParameter returns the HTTP Header value of a Header name or empty if missing -func (r *Request) HeaderParameter(name string) string { - return r.Request.Header.Get(name) -} - -// ReadEntity checks the Accept header and reads the content into the entityPointer. -func (r *Request) ReadEntity(entityPointer interface{}) (err error) { - contentType := r.Request.Header.Get(HEADER_ContentType) - contentEncoding := r.Request.Header.Get(HEADER_ContentEncoding) - - // check if the request body needs decompression - if ENCODING_GZIP == contentEncoding { - gzipReader := currentCompressorProvider.AcquireGzipReader() - defer currentCompressorProvider.ReleaseGzipReader(gzipReader) - gzipReader.Reset(r.Request.Body) - r.Request.Body = gzipReader - } else if ENCODING_DEFLATE == contentEncoding { - zlibReader, err := zlib.NewReader(r.Request.Body) - if err != nil { - return err - } - r.Request.Body = zlibReader - } - - // lookup the EntityReader, use defaultRequestContentType if needed and provided - entityReader, ok := entityAccessRegistry.accessorAt(contentType) - if !ok { - if len(defaultRequestContentType) != 0 { - entityReader, ok = entityAccessRegistry.accessorAt(defaultRequestContentType) - } - if !ok { - return NewError(http.StatusBadRequest, "Unable to unmarshal content of type:"+contentType) - } - } - return entityReader.Read(r, entityPointer) -} - -// SetAttribute adds or replaces the attribute with the given value. -func (r *Request) SetAttribute(name string, value interface{}) { - r.attributes[name] = value -} - -// Attribute returns the value associated to the given name. Returns nil if absent. -func (r Request) Attribute(name string) interface{} { - return r.attributes[name] -} - -// SelectedRoutePath root path + route path that matched the request, e.g. /meetings/{id}/attendees -func (r Request) SelectedRoutePath() string { - return r.selectedRoute.Path -} - -// SelectedRoute return the Route that selected by the container -func (r Request) SelectedRoute() RouteReader { - return routeAccessor{route: r.selectedRoute} -} diff --git a/vendor/github.com/emicklei/go-restful/response.go b/vendor/github.com/emicklei/go-restful/response.go deleted file mode 100644 index 8f0b56aa2..000000000 --- a/vendor/github.com/emicklei/go-restful/response.go +++ /dev/null @@ -1,256 +0,0 @@ -package restful - -// Copyright 2013 Ernest Micklei. All rights reserved. -// Use of this source code is governed by a license -// that can be found in the LICENSE file. - -import ( - "bufio" - "errors" - "net" - "net/http" -) - -// DefaultResponseMimeType is DEPRECATED, use DefaultResponseContentType(mime) -var DefaultResponseMimeType string - -//PrettyPrintResponses controls the indentation feature of XML and JSON serialization -var PrettyPrintResponses = true - -// Response is a wrapper on the actual http ResponseWriter -// It provides several convenience methods to prepare and write response content. -type Response struct { - http.ResponseWriter - requestAccept string // mime-type what the Http Request says it wants to receive - routeProduces []string // mime-types what the Route says it can produce - statusCode int // HTTP status code that has been written explicitly (if zero then net/http has written 200) - contentLength int // number of bytes written for the response body - prettyPrint bool // controls the indentation feature of XML and JSON serialization. It is initialized using var PrettyPrintResponses. - err error // err property is kept when WriteError is called - hijacker http.Hijacker // if underlying ResponseWriter supports it -} - -// NewResponse creates a new response based on a http ResponseWriter. -func NewResponse(httpWriter http.ResponseWriter) *Response { - hijacker, _ := httpWriter.(http.Hijacker) - return &Response{ResponseWriter: httpWriter, routeProduces: []string{}, statusCode: http.StatusOK, prettyPrint: PrettyPrintResponses, hijacker: hijacker} -} - -// DefaultResponseContentType set a default. -// If Accept header matching fails, fall back to this type. -// Valid values are restful.MIME_JSON and restful.MIME_XML -// Example: -// restful.DefaultResponseContentType(restful.MIME_JSON) -func DefaultResponseContentType(mime string) { - DefaultResponseMimeType = mime -} - -// InternalServerError writes the StatusInternalServerError header. -// DEPRECATED, use WriteErrorString(http.StatusInternalServerError,reason) -func (r Response) InternalServerError() Response { - r.WriteHeader(http.StatusInternalServerError) - return r -} - -// Hijack implements the http.Hijacker interface. This expands -// the Response to fulfill http.Hijacker if the underlying -// http.ResponseWriter supports it. -func (r *Response) Hijack() (net.Conn, *bufio.ReadWriter, error) { - if r.hijacker == nil { - return nil, nil, errors.New("http.Hijacker not implemented by underlying http.ResponseWriter") - } - return r.hijacker.Hijack() -} - -// PrettyPrint changes whether this response must produce pretty (line-by-line, indented) JSON or XML output. -func (r *Response) PrettyPrint(bePretty bool) { - r.prettyPrint = bePretty -} - -// AddHeader is a shortcut for .Header().Add(header,value) -func (r Response) AddHeader(header string, value string) Response { - r.Header().Add(header, value) - return r -} - -// SetRequestAccepts tells the response what Mime-type(s) the HTTP request said it wants to accept. Exposed for testing. -func (r *Response) SetRequestAccepts(mime string) { - r.requestAccept = mime -} - -// EntityWriter returns the registered EntityWriter that the entity (requested resource) -// can write according to what the request wants (Accept) and what the Route can produce or what the restful defaults say. -// If called before WriteEntity and WriteHeader then a false return value can be used to write a 406: Not Acceptable. -func (r *Response) EntityWriter() (EntityReaderWriter, bool) { - sorted := sortedMimes(r.requestAccept) - for _, eachAccept := range sorted { - for _, eachProduce := range r.routeProduces { - if eachProduce == eachAccept.media { - if w, ok := entityAccessRegistry.accessorAt(eachAccept.media); ok { - return w, true - } - } - } - if eachAccept.media == "*/*" { - for _, each := range r.routeProduces { - if w, ok := entityAccessRegistry.accessorAt(each); ok { - return w, true - } - } - } - } - // if requestAccept is empty - writer, ok := entityAccessRegistry.accessorAt(r.requestAccept) - if !ok { - // if not registered then fallback to the defaults (if set) - if DefaultResponseMimeType == MIME_JSON { - return entityAccessRegistry.accessorAt(MIME_JSON) - } - if DefaultResponseMimeType == MIME_XML { - return entityAccessRegistry.accessorAt(MIME_XML) - } - // Fallback to whatever the route says it can produce. - // https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html - for _, each := range r.routeProduces { - if w, ok := entityAccessRegistry.accessorAt(each); ok { - return w, true - } - } - if trace { - traceLogger.Printf("no registered EntityReaderWriter found for %s", r.requestAccept) - } - } - return writer, ok -} - -// WriteEntity calls WriteHeaderAndEntity with Http Status OK (200) -func (r *Response) WriteEntity(value interface{}) error { - return r.WriteHeaderAndEntity(http.StatusOK, value) -} - -// WriteHeaderAndEntity marshals the value using the representation denoted by the Accept Header and the registered EntityWriters. -// If no Accept header is specified (or */*) then respond with the Content-Type as specified by the first in the Route.Produces. -// If an Accept header is specified then respond with the Content-Type as specified by the first in the Route.Produces that is matched with the Accept header. -// If the value is nil then no response is send except for the Http status. You may want to call WriteHeader(http.StatusNotFound) instead. -// If there is no writer available that can represent the value in the requested MIME type then Http Status NotAcceptable is written. -// Current implementation ignores any q-parameters in the Accept Header. -// Returns an error if the value could not be written on the response. -func (r *Response) WriteHeaderAndEntity(status int, value interface{}) error { - writer, ok := r.EntityWriter() - if !ok { - r.WriteHeader(http.StatusNotAcceptable) - return nil - } - return writer.Write(r, status, value) -} - -// WriteAsXml is a convenience method for writing a value in xml (requires Xml tags on the value) -// It uses the standard encoding/xml package for marshalling the value ; not using a registered EntityReaderWriter. -func (r *Response) WriteAsXml(value interface{}) error { - return writeXML(r, http.StatusOK, MIME_XML, value) -} - -// WriteHeaderAndXml is a convenience method for writing a status and value in xml (requires Xml tags on the value) -// It uses the standard encoding/xml package for marshalling the value ; not using a registered EntityReaderWriter. -func (r *Response) WriteHeaderAndXml(status int, value interface{}) error { - return writeXML(r, status, MIME_XML, value) -} - -// WriteAsJson is a convenience method for writing a value in json. -// It uses the standard encoding/json package for marshalling the value ; not using a registered EntityReaderWriter. -func (r *Response) WriteAsJson(value interface{}) error { - return writeJSON(r, http.StatusOK, MIME_JSON, value) -} - -// WriteJson is a convenience method for writing a value in Json with a given Content-Type. -// It uses the standard encoding/json package for marshalling the value ; not using a registered EntityReaderWriter. -func (r *Response) WriteJson(value interface{}, contentType string) error { - return writeJSON(r, http.StatusOK, contentType, value) -} - -// WriteHeaderAndJson is a convenience method for writing the status and a value in Json with a given Content-Type. -// It uses the standard encoding/json package for marshalling the value ; not using a registered EntityReaderWriter. -func (r *Response) WriteHeaderAndJson(status int, value interface{}, contentType string) error { - return writeJSON(r, status, contentType, value) -} - -// WriteError writes the http status and the error string on the response. err can be nil. -// Return an error if writing was not successful. -func (r *Response) WriteError(httpStatus int, err error) (writeErr error) { - r.err = err - if err == nil { - writeErr = r.WriteErrorString(httpStatus, "") - } else { - writeErr = r.WriteErrorString(httpStatus, err.Error()) - } - return writeErr -} - -// WriteServiceError is a convenience method for a responding with a status and a ServiceError -func (r *Response) WriteServiceError(httpStatus int, err ServiceError) error { - r.err = err - return r.WriteHeaderAndEntity(httpStatus, err) -} - -// WriteErrorString is a convenience method for an error status with the actual error -func (r *Response) WriteErrorString(httpStatus int, errorReason string) error { - if r.err == nil { - // if not called from WriteError - r.err = errors.New(errorReason) - } - r.WriteHeader(httpStatus) - if _, err := r.Write([]byte(errorReason)); err != nil { - return err - } - return nil -} - -// Flush implements http.Flusher interface, which sends any buffered data to the client. -func (r *Response) Flush() { - if f, ok := r.ResponseWriter.(http.Flusher); ok { - f.Flush() - } else if trace { - traceLogger.Printf("ResponseWriter %v doesn't support Flush", r) - } -} - -// WriteHeader is overridden to remember the Status Code that has been written. -// Changes to the Header of the response have no effect after this. -func (r *Response) WriteHeader(httpStatus int) { - r.statusCode = httpStatus - r.ResponseWriter.WriteHeader(httpStatus) -} - -// StatusCode returns the code that has been written using WriteHeader. -func (r Response) StatusCode() int { - if 0 == r.statusCode { - // no status code has been written yet; assume OK - return http.StatusOK - } - return r.statusCode -} - -// Write writes the data to the connection as part of an HTTP reply. -// Write is part of http.ResponseWriter interface. -func (r *Response) Write(bytes []byte) (int, error) { - written, err := r.ResponseWriter.Write(bytes) - r.contentLength += written - return written, err -} - -// ContentLength returns the number of bytes written for the response content. -// Note that this value is only correct if all data is written through the Response using its Write* methods. -// Data written directly using the underlying http.ResponseWriter is not accounted for. -func (r Response) ContentLength() int { - return r.contentLength -} - -// CloseNotify is part of http.CloseNotifier interface -func (r Response) CloseNotify() <-chan bool { - return r.ResponseWriter.(http.CloseNotifier).CloseNotify() -} - -// Error returns the err created by WriteError -func (r Response) Error() error { - return r.err -} diff --git a/vendor/github.com/emicklei/go-restful/route.go b/vendor/github.com/emicklei/go-restful/route.go deleted file mode 100644 index 6ac261293..000000000 --- a/vendor/github.com/emicklei/go-restful/route.go +++ /dev/null @@ -1,177 +0,0 @@ -package restful - -// Copyright 2013 Ernest Micklei. All rights reserved. -// Use of this source code is governed by a license -// that can be found in the LICENSE file. - -import ( - "net/http" - "strings" -) - -// RouteFunction declares the signature of a function that can be bound to a Route. -type RouteFunction func(*Request, *Response) - -// RouteSelectionConditionFunction declares the signature of a function that -// can be used to add extra conditional logic when selecting whether the route -// matches the HTTP request. -type RouteSelectionConditionFunction func(httpRequest *http.Request) bool - -// Route binds a HTTP Method,Path,Consumes combination to a RouteFunction. -type Route struct { - Method string - Produces []string - Consumes []string - Path string // webservice root path + described path - Function RouteFunction - Filters []FilterFunction - If []RouteSelectionConditionFunction - - // cached values for dispatching - relativePath string - pathParts []string - pathExpr *pathExpression // cached compilation of relativePath as RegExp - - // documentation - Doc string - Notes string - Operation string - ParameterDocs []*Parameter - ResponseErrors map[int]ResponseError - DefaultResponse *ResponseError - ReadSample, WriteSample interface{} // structs that model an example request or response payload - - // Extra information used to store custom information about the route. - Metadata map[string]interface{} - - // marks a route as deprecated - Deprecated bool - - //Overrides the container.contentEncodingEnabled - contentEncodingEnabled *bool - - // indicate route path has custom verb - hasCustomVerb bool - - // if a request does not include a content-type header then - // depending on the method, it may return a 415 Unsupported Media - // Must have uppercase HTTP Method names such as GET,HEAD,OPTIONS,... - allowedMethodsWithoutContentType []string -} - -// Initialize for Route -func (r *Route) postBuild() { - r.pathParts = tokenizePath(r.Path) - r.hasCustomVerb = hasCustomVerb(r.Path) -} - -// Create Request and Response from their http versions -func (r *Route) wrapRequestResponse(httpWriter http.ResponseWriter, httpRequest *http.Request, pathParams map[string]string) (*Request, *Response) { - wrappedRequest := NewRequest(httpRequest) - wrappedRequest.pathParameters = pathParams - wrappedRequest.selectedRoute = r - wrappedResponse := NewResponse(httpWriter) - wrappedResponse.requestAccept = httpRequest.Header.Get(HEADER_Accept) - wrappedResponse.routeProduces = r.Produces - return wrappedRequest, wrappedResponse -} - -func stringTrimSpaceCutset(r rune) bool { - return r == ' ' -} - -// Return whether the mimeType matches to what this Route can produce. -func (r Route) matchesAccept(mimeTypesWithQuality string) bool { - remaining := mimeTypesWithQuality - for { - var mimeType string - if end := strings.Index(remaining, ","); end == -1 { - mimeType, remaining = remaining, "" - } else { - mimeType, remaining = remaining[:end], remaining[end+1:] - } - if quality := strings.Index(mimeType, ";"); quality != -1 { - mimeType = mimeType[:quality] - } - mimeType = strings.TrimFunc(mimeType, stringTrimSpaceCutset) - if mimeType == "*/*" { - return true - } - for _, producibleType := range r.Produces { - if producibleType == "*/*" || producibleType == mimeType { - return true - } - } - if len(remaining) == 0 { - return false - } - } -} - -// Return whether this Route can consume content with a type specified by mimeTypes (can be empty). -func (r Route) matchesContentType(mimeTypes string) bool { - - if len(r.Consumes) == 0 { - // did not specify what it can consume ; any media type (“*/*”) is assumed - return true - } - - if len(mimeTypes) == 0 { - // idempotent methods with (most-likely or guaranteed) empty content match missing Content-Type - m := r.Method - // if route specifies less or non-idempotent methods then use that - if len(r.allowedMethodsWithoutContentType) > 0 { - for _, each := range r.allowedMethodsWithoutContentType { - if m == each { - return true - } - } - } else { - if m == "GET" || m == "HEAD" || m == "OPTIONS" || m == "DELETE" || m == "TRACE" { - return true - } - } - // proceed with default - mimeTypes = MIME_OCTET - } - - remaining := mimeTypes - for { - var mimeType string - if end := strings.Index(remaining, ","); end == -1 { - mimeType, remaining = remaining, "" - } else { - mimeType, remaining = remaining[:end], remaining[end+1:] - } - if quality := strings.Index(mimeType, ";"); quality != -1 { - mimeType = mimeType[:quality] - } - mimeType = strings.TrimFunc(mimeType, stringTrimSpaceCutset) - for _, consumeableType := range r.Consumes { - if consumeableType == "*/*" || consumeableType == mimeType { - return true - } - } - if len(remaining) == 0 { - return false - } - } -} - -// Tokenize an URL path using the slash separator ; the result does not have empty tokens -func tokenizePath(path string) []string { - if "/" == path { - return nil - } - return strings.Split(strings.Trim(path, "/"), "/") -} - -// for debugging -func (r Route) String() string { - return r.Method + " " + r.Path -} - -// EnableContentEncoding (default=false) allows for GZIP or DEFLATE encoding of responses. Overrides the container.contentEncodingEnabled value. -func (r Route) EnableContentEncoding(enabled bool) { - r.contentEncodingEnabled = &enabled -} diff --git a/vendor/github.com/emicklei/go-restful/route_builder.go b/vendor/github.com/emicklei/go-restful/route_builder.go deleted file mode 100644 index 1d67a4c23..000000000 --- a/vendor/github.com/emicklei/go-restful/route_builder.go +++ /dev/null @@ -1,364 +0,0 @@ -package restful - -// Copyright 2013 Ernest Micklei. All rights reserved. -// Use of this source code is governed by a license -// that can be found in the LICENSE file. - -import ( - "fmt" - "os" - "reflect" - "runtime" - "strings" - "sync/atomic" - - "github.com/emicklei/go-restful/log" -) - -// RouteBuilder is a helper to construct Routes. -type RouteBuilder struct { - rootPath string - currentPath string - produces []string - consumes []string - httpMethod string // required - function RouteFunction // required - filters []FilterFunction - conditions []RouteSelectionConditionFunction - allowedMethodsWithoutContentType []string // see Route - - typeNameHandleFunc TypeNameHandleFunction // required - - // documentation - doc string - notes string - operation string - readSample, writeSample interface{} - parameters []*Parameter - errorMap map[int]ResponseError - defaultResponse *ResponseError - metadata map[string]interface{} - deprecated bool - contentEncodingEnabled *bool -} - -// Do evaluates each argument with the RouteBuilder itself. -// This allows you to follow DRY principles without breaking the fluent programming style. -// Example: -// ws.Route(ws.DELETE("/{name}").To(t.deletePerson).Do(Returns200, Returns500)) -// -// func Returns500(b *RouteBuilder) { -// b.Returns(500, "Internal Server Error", restful.ServiceError{}) -// } -func (b *RouteBuilder) Do(oneArgBlocks ...func(*RouteBuilder)) *RouteBuilder { - for _, each := range oneArgBlocks { - each(b) - } - return b -} - -// To bind the route to a function. -// If this route is matched with the incoming Http Request then call this function with the *Request,*Response pair. Required. -func (b *RouteBuilder) To(function RouteFunction) *RouteBuilder { - b.function = function - return b -} - -// Method specifies what HTTP method to match. Required. -func (b *RouteBuilder) Method(method string) *RouteBuilder { - b.httpMethod = method - return b -} - -// Produces specifies what MIME types can be produced ; the matched one will appear in the Content-Type Http header. -func (b *RouteBuilder) Produces(mimeTypes ...string) *RouteBuilder { - b.produces = mimeTypes - return b -} - -// Consumes specifies what MIME types can be consumes ; the Accept Http header must matched any of these -func (b *RouteBuilder) Consumes(mimeTypes ...string) *RouteBuilder { - b.consumes = mimeTypes - return b -} - -// Path specifies the relative (w.r.t WebService root path) URL path to match. Default is "/". -func (b *RouteBuilder) Path(subPath string) *RouteBuilder { - b.currentPath = subPath - return b -} - -// Doc tells what this route is all about. Optional. -func (b *RouteBuilder) Doc(documentation string) *RouteBuilder { - b.doc = documentation - return b -} - -// Notes is a verbose explanation of the operation behavior. Optional. -func (b *RouteBuilder) Notes(notes string) *RouteBuilder { - b.notes = notes - return b -} - -// Reads tells what resource type will be read from the request payload. Optional. -// A parameter of type "body" is added ,required is set to true and the dataType is set to the qualified name of the sample's type. -func (b *RouteBuilder) Reads(sample interface{}, optionalDescription ...string) *RouteBuilder { - fn := b.typeNameHandleFunc - if fn == nil { - fn = reflectTypeName - } - typeAsName := fn(sample) - description := "" - if len(optionalDescription) > 0 { - description = optionalDescription[0] - } - b.readSample = sample - bodyParameter := &Parameter{&ParameterData{Name: "body", Description: description}} - bodyParameter.beBody() - bodyParameter.Required(true) - bodyParameter.DataType(typeAsName) - b.Param(bodyParameter) - return b -} - -// ParameterNamed returns a Parameter already known to the RouteBuilder. Returns nil if not. -// Use this to modify or extend information for the Parameter (through its Data()). -func (b RouteBuilder) ParameterNamed(name string) (p *Parameter) { - for _, each := range b.parameters { - if each.Data().Name == name { - return each - } - } - return p -} - -// Writes tells what resource type will be written as the response payload. Optional. -func (b *RouteBuilder) Writes(sample interface{}) *RouteBuilder { - b.writeSample = sample - return b -} - -// Param allows you to document the parameters of the Route. It adds a new Parameter (does not check for duplicates). -func (b *RouteBuilder) Param(parameter *Parameter) *RouteBuilder { - if b.parameters == nil { - b.parameters = []*Parameter{} - } - b.parameters = append(b.parameters, parameter) - return b -} - -// Operation allows you to document what the actual method/function call is of the Route. -// Unless called, the operation name is derived from the RouteFunction set using To(..). -func (b *RouteBuilder) Operation(name string) *RouteBuilder { - b.operation = name - return b -} - -// ReturnsError is deprecated, use Returns instead. -func (b *RouteBuilder) ReturnsError(code int, message string, model interface{}) *RouteBuilder { - log.Print("ReturnsError is deprecated, use Returns instead.") - return b.Returns(code, message, model) -} - -// Returns allows you to document what responses (errors or regular) can be expected. -// The model parameter is optional ; either pass a struct instance or use nil if not applicable. -func (b *RouteBuilder) Returns(code int, message string, model interface{}) *RouteBuilder { - err := ResponseError{ - Code: code, - Message: message, - Model: model, - IsDefault: false, // this field is deprecated, use default response instead. - } - // lazy init because there is no NewRouteBuilder (yet) - if b.errorMap == nil { - b.errorMap = map[int]ResponseError{} - } - b.errorMap[code] = err - return b -} - -// ReturnsWithHeaders is similar to Returns, but can specify response headers -func (b *RouteBuilder) ReturnsWithHeaders(code int, message string, model interface{}, headers map[string]Header) *RouteBuilder { - b.Returns(code, message, model) - err := b.errorMap[code] - err.Headers = headers - b.errorMap[code] = err - return b -} - -// DefaultReturns is a special Returns call that sets the default of the response. -func (b *RouteBuilder) DefaultReturns(message string, model interface{}) *RouteBuilder { - b.defaultResponse = &ResponseError{ - Message: message, - Model: model, - } - return b -} - -// Metadata adds or updates a key=value pair to the metadata map. -func (b *RouteBuilder) Metadata(key string, value interface{}) *RouteBuilder { - if b.metadata == nil { - b.metadata = map[string]interface{}{} - } - b.metadata[key] = value - return b -} - -// Deprecate sets the value of deprecated to true. Deprecated routes have a special UI treatment to warn against use -func (b *RouteBuilder) Deprecate() *RouteBuilder { - b.deprecated = true - return b -} - -// AllowedMethodsWithoutContentType overides the default list GET,HEAD,OPTIONS,DELETE,TRACE -// If a request does not include a content-type header then -// depending on the method, it may return a 415 Unsupported Media. -// Must have uppercase HTTP Method names such as GET,HEAD,OPTIONS,... -func (b *RouteBuilder) AllowedMethodsWithoutContentType(methods []string) *RouteBuilder { - b.allowedMethodsWithoutContentType = methods - return b -} - -// ResponseError represents a response; not necessarily an error. -type ResponseError struct { - Code int - Message string - Model interface{} - Headers map[string]Header - IsDefault bool -} - -// Header describes a header for a response of the API -// -// For more information: http://goo.gl/8us55a#headerObject -type Header struct { - *Items - Description string -} - -// Items describe swagger simple schemas for headers -type Items struct { - Type string - Format string - Items *Items - CollectionFormat string - Default interface{} -} - -func (b *RouteBuilder) servicePath(path string) *RouteBuilder { - b.rootPath = path - return b -} - -// Filter appends a FilterFunction to the end of filters for this Route to build. -func (b *RouteBuilder) Filter(filter FilterFunction) *RouteBuilder { - b.filters = append(b.filters, filter) - return b -} - -// If sets a condition function that controls matching the Route based on custom logic. -// The condition function is provided the HTTP request and should return true if the route -// should be considered. -// -// Efficiency note: the condition function is called before checking the method, produces, and -// consumes criteria, so that the correct HTTP status code can be returned. -// -// Lifecycle note: no filter functions have been called prior to calling the condition function, -// so the condition function should not depend on any context that might be set up by container -// or route filters. -func (b *RouteBuilder) If(condition RouteSelectionConditionFunction) *RouteBuilder { - b.conditions = append(b.conditions, condition) - return b -} - -// ContentEncodingEnabled allows you to override the Containers value for auto-compressing this route response. -func (b *RouteBuilder) ContentEncodingEnabled(enabled bool) *RouteBuilder { - b.contentEncodingEnabled = &enabled - return b -} - -// If no specific Route path then set to rootPath -// If no specific Produces then set to rootProduces -// If no specific Consumes then set to rootConsumes -func (b *RouteBuilder) copyDefaults(rootProduces, rootConsumes []string) { - if len(b.produces) == 0 { - b.produces = rootProduces - } - if len(b.consumes) == 0 { - b.consumes = rootConsumes - } -} - -// typeNameHandler sets the function that will convert types to strings in the parameter -// and model definitions. -func (b *RouteBuilder) typeNameHandler(handler TypeNameHandleFunction) *RouteBuilder { - b.typeNameHandleFunc = handler - return b -} - -// Build creates a new Route using the specification details collected by the RouteBuilder -func (b *RouteBuilder) Build() Route { - pathExpr, err := newPathExpression(b.currentPath) - if err != nil { - log.Printf("Invalid path:%s because:%v", b.currentPath, err) - os.Exit(1) - } - if b.function == nil { - log.Printf("No function specified for route:" + b.currentPath) - os.Exit(1) - } - operationName := b.operation - if len(operationName) == 0 && b.function != nil { - // extract from definition - operationName = nameOfFunction(b.function) - } - route := Route{ - Method: b.httpMethod, - Path: concatPath(b.rootPath, b.currentPath), - Produces: b.produces, - Consumes: b.consumes, - Function: b.function, - Filters: b.filters, - If: b.conditions, - relativePath: b.currentPath, - pathExpr: pathExpr, - Doc: b.doc, - Notes: b.notes, - Operation: operationName, - ParameterDocs: b.parameters, - ResponseErrors: b.errorMap, - DefaultResponse: b.defaultResponse, - ReadSample: b.readSample, - WriteSample: b.writeSample, - Metadata: b.metadata, - Deprecated: b.deprecated, - contentEncodingEnabled: b.contentEncodingEnabled, - allowedMethodsWithoutContentType: b.allowedMethodsWithoutContentType, - } - route.postBuild() - return route -} - -func concatPath(path1, path2 string) string { - return strings.TrimRight(path1, "/") + "/" + strings.TrimLeft(path2, "/") -} - -var anonymousFuncCount int32 - -// nameOfFunction returns the short name of the function f for documentation. -// It uses a runtime feature for debugging ; its value may change for later Go versions. -func nameOfFunction(f interface{}) string { - fun := runtime.FuncForPC(reflect.ValueOf(f).Pointer()) - tokenized := strings.Split(fun.Name(), ".") - last := tokenized[len(tokenized)-1] - last = strings.TrimSuffix(last, ")·fm") // < Go 1.5 - last = strings.TrimSuffix(last, ")-fm") // Go 1.5 - last = strings.TrimSuffix(last, "·fm") // < Go 1.5 - last = strings.TrimSuffix(last, "-fm") // Go 1.5 - if last == "func1" { // this could mean conflicts in API docs - val := atomic.AddInt32(&anonymousFuncCount, 1) - last = "func" + fmt.Sprintf("%d", val) - atomic.StoreInt32(&anonymousFuncCount, val) - } - return last -} diff --git a/vendor/github.com/emicklei/go-restful/route_reader.go b/vendor/github.com/emicklei/go-restful/route_reader.go deleted file mode 100644 index c9f4ee75f..000000000 --- a/vendor/github.com/emicklei/go-restful/route_reader.go +++ /dev/null @@ -1,66 +0,0 @@ -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 -} diff --git a/vendor/github.com/emicklei/go-restful/router.go b/vendor/github.com/emicklei/go-restful/router.go deleted file mode 100644 index 19078af1c..000000000 --- a/vendor/github.com/emicklei/go-restful/router.go +++ /dev/null @@ -1,20 +0,0 @@ -package restful - -// Copyright 2013 Ernest Micklei. All rights reserved. -// Use of this source code is governed by a license -// that can be found in the LICENSE file. - -import "net/http" - -// A RouteSelector finds the best matching Route given the input HTTP Request -// RouteSelectors can optionally also implement the PathProcessor interface to also calculate the -// path parameters after the route has been selected. -type RouteSelector interface { - - // SelectRoute finds a Route given the input HTTP Request and a list of WebServices. - // It returns a selected Route and its containing WebService or an error indicating - // a problem. - SelectRoute( - webServices []*WebService, - httpRequest *http.Request) (selectedService *WebService, selected *Route, err error) -} diff --git a/vendor/github.com/emicklei/go-restful/service_error.go b/vendor/github.com/emicklei/go-restful/service_error.go deleted file mode 100644 index a41575469..000000000 --- a/vendor/github.com/emicklei/go-restful/service_error.go +++ /dev/null @@ -1,32 +0,0 @@ -package restful - -// Copyright 2013 Ernest Micklei. All rights reserved. -// Use of this source code is governed by a license -// that can be found in the LICENSE file. - -import ( - "fmt" - "net/http" -) - -// ServiceError is a transport object to pass information about a non-Http error occurred in a WebService while processing a request. -type ServiceError struct { - Code int - Message string - Header http.Header -} - -// NewError returns a ServiceError using the code and reason -func NewError(code int, message string) ServiceError { - return ServiceError{Code: code, Message: message} -} - -// NewErrorWithHeader returns a ServiceError using the code, reason and header -func NewErrorWithHeader(code int, message string, header http.Header) ServiceError { - return ServiceError{Code: code, Message: message, Header: header} -} - -// Error returns a text representation of the service error -func (s ServiceError) Error() string { - return fmt.Sprintf("[ServiceError:%v] %v", s.Code, s.Message) -} diff --git a/vendor/github.com/emicklei/go-restful/v3/CHANGES.md b/vendor/github.com/emicklei/go-restful/v3/CHANGES.md index 02a73ccfd..352018e70 100644 --- a/vendor/github.com/emicklei/go-restful/v3/CHANGES.md +++ b/vendor/github.com/emicklei/go-restful/v3/CHANGES.md @@ -1,5 +1,10 @@ # Change history of go-restful +## [v3.10.2] - 2023-03-09 + +- introduced MergePathStrategy to be able to revert behaviour of path concatenation to 3.9.0 + see comment in Readme how to customize this behaviour. + ## [v3.10.1] - 2022-11-19 - fix broken 3.10.0 by using path package for joining paths diff --git a/vendor/github.com/emicklei/go-restful/v3/README.md b/vendor/github.com/emicklei/go-restful/v3/README.md index 0625359dc..85da90128 100644 --- a/vendor/github.com/emicklei/go-restful/v3/README.md +++ b/vendor/github.com/emicklei/go-restful/v3/README.md @@ -96,6 +96,10 @@ There are several hooks to customize the behavior of the go-restful package. - Compression - Encoders for other serializers - Use [jsoniter](https://github.com/json-iterator/go) by building this package using a build tag, e.g. `go build -tags=jsoniter .` +- Use the variable `MergePathStrategy` to change the behaviour of composing the Route path given a root path and a local route path + - versions >= 3.10.1 has set the value to `PathJoinStrategy` that fixes a reported [security issue](https://github.com/advisories/GHSA-r48q-9g5r-8q2h) but may cause your services not to work correctly anymore. + - versions <= 3.9 had the behaviour that can be restored in newer versions by setting the value to `TrimSlashStrategy`. + - you can set value to a custom implementation (must implement MergePathStrategyFunc) ## Resources diff --git a/vendor/github.com/emicklei/go-restful/v3/route_builder.go b/vendor/github.com/emicklei/go-restful/v3/route_builder.go index 830ebf148..827f471de 100644 --- a/vendor/github.com/emicklei/go-restful/v3/route_builder.go +++ b/vendor/github.com/emicklei/go-restful/v3/route_builder.go @@ -353,8 +353,28 @@ func (b *RouteBuilder) Build() Route { return route } -func concatPath(path1, path2 string) string { - return path.Join(path1, path2) +type MergePathStrategyFunc func(rootPath, routePath string) string + +var ( + // behavior >= 3.10 + PathJoinStrategy = func(rootPath, routePath string) string { + return path.Join(rootPath, routePath) + } + + // behavior <= 3.9 + TrimSlashStrategy = func(rootPath, routePath string) string { + return strings.TrimRight(rootPath, "/") + "/" + strings.TrimLeft(routePath, "/") + } + + // MergePathStrategy is the active strategy for merging a Route path when building the routing of all WebServices. + // The value is set to PathJoinStrategy + // PathJoinStrategy is a strategy that is more strict [Security - PRISMA-2022-0227] + MergePathStrategy = PathJoinStrategy +) + +// merge two paths using the current (package global) merge path strategy. +func concatPath(rootPath, routePath string) string { + return MergePathStrategy(rootPath, routePath) } var anonymousFuncCount int32 diff --git a/vendor/github.com/emicklei/go-restful/web_service.go b/vendor/github.com/emicklei/go-restful/web_service.go deleted file mode 100644 index 2eac41497..000000000 --- a/vendor/github.com/emicklei/go-restful/web_service.go +++ /dev/null @@ -1,307 +0,0 @@ -package restful - -import ( - "errors" - "os" - "reflect" - "sync" - - "github.com/emicklei/go-restful/log" -) - -// Copyright 2013 Ernest Micklei. All rights reserved. -// Use of this source code is governed by a license -// that can be found in the LICENSE file. - -// WebService holds a collection of Route values that bind a Http Method + URL Path to a function. -type WebService struct { - rootPath string - pathExpr *pathExpression // cached compilation of rootPath as RegExp - routes []Route - produces []string - consumes []string - pathParameters []*Parameter - filters []FilterFunction - documentation string - apiVersion string - - typeNameHandleFunc TypeNameHandleFunction - - dynamicRoutes bool - - // protects 'routes' if dynamic routes are enabled - routesLock sync.RWMutex -} - -func (w *WebService) SetDynamicRoutes(enable bool) { - w.dynamicRoutes = enable -} - -// TypeNameHandleFunction declares functions that can handle translating the name of a sample object -// into the restful documentation for the service. -type TypeNameHandleFunction func(sample interface{}) string - -// TypeNameHandler sets the function that will convert types to strings in the parameter -// and model definitions. If not set, the web service will invoke -// reflect.TypeOf(object).String(). -func (w *WebService) TypeNameHandler(handler TypeNameHandleFunction) *WebService { - w.typeNameHandleFunc = handler - return w -} - -// reflectTypeName is the default TypeNameHandleFunction and for a given object -// returns the name that Go identifies it with (e.g. "string" or "v1.Object") via -// the reflection API. -func reflectTypeName(sample interface{}) string { - return reflect.TypeOf(sample).String() -} - -// compilePathExpression ensures that the path is compiled into a RegEx for those routers that need it. -func (w *WebService) compilePathExpression() { - compiled, err := newPathExpression(w.rootPath) - if err != nil { - log.Printf("invalid path:%s because:%v", w.rootPath, err) - os.Exit(1) - } - w.pathExpr = compiled -} - -// ApiVersion sets the API version for documentation purposes. -func (w *WebService) ApiVersion(apiVersion string) *WebService { - w.apiVersion = apiVersion - return w -} - -// Version returns the API version for documentation purposes. -func (w *WebService) Version() string { return w.apiVersion } - -// Path specifies the root URL template path of the WebService. -// All Routes will be relative to this path. -func (w *WebService) Path(root string) *WebService { - w.rootPath = root - if len(w.rootPath) == 0 { - w.rootPath = "/" - } - w.compilePathExpression() - return w -} - -// Param adds a PathParameter to document parameters used in the root path. -func (w *WebService) Param(parameter *Parameter) *WebService { - if w.pathParameters == nil { - w.pathParameters = []*Parameter{} - } - w.pathParameters = append(w.pathParameters, parameter) - return w -} - -// PathParameter creates a new Parameter of kind Path for documentation purposes. -// It is initialized as required with string as its DataType. -func (w *WebService) PathParameter(name, description string) *Parameter { - return PathParameter(name, description) -} - -// PathParameter creates a new Parameter of kind Path for documentation purposes. -// It is initialized as required with string as its DataType. -func PathParameter(name, description string) *Parameter { - p := &Parameter{&ParameterData{Name: name, Description: description, Required: true, DataType: "string"}} - p.bePath() - return p -} - -// QueryParameter creates a new Parameter of kind Query for documentation purposes. -// It is initialized as not required with string as its DataType. -func (w *WebService) QueryParameter(name, description string) *Parameter { - return QueryParameter(name, description) -} - -// QueryParameter creates a new Parameter of kind Query for documentation purposes. -// It is initialized as not required with string as its DataType. -func QueryParameter(name, description string) *Parameter { - p := &Parameter{&ParameterData{Name: name, Description: description, Required: false, DataType: "string", CollectionFormat: CollectionFormatCSV.String()}} - p.beQuery() - return p -} - -// BodyParameter creates a new Parameter of kind Body for documentation purposes. -// It is initialized as required without a DataType. -func (w *WebService) BodyParameter(name, description string) *Parameter { - return BodyParameter(name, description) -} - -// BodyParameter creates a new Parameter of kind Body for documentation purposes. -// It is initialized as required without a DataType. -func BodyParameter(name, description string) *Parameter { - p := &Parameter{&ParameterData{Name: name, Description: description, Required: true}} - p.beBody() - return p -} - -// HeaderParameter creates a new Parameter of kind (Http) Header for documentation purposes. -// It is initialized as not required with string as its DataType. -func (w *WebService) HeaderParameter(name, description string) *Parameter { - return HeaderParameter(name, description) -} - -// HeaderParameter creates a new Parameter of kind (Http) Header for documentation purposes. -// It is initialized as not required with string as its DataType. -func HeaderParameter(name, description string) *Parameter { - p := &Parameter{&ParameterData{Name: name, Description: description, Required: false, DataType: "string"}} - p.beHeader() - return p -} - -// FormParameter creates a new Parameter of kind Form (using application/x-www-form-urlencoded) for documentation purposes. -// It is initialized as required with string as its DataType. -func (w *WebService) FormParameter(name, description string) *Parameter { - return FormParameter(name, description) -} - -// FormParameter creates a new Parameter of kind Form (using application/x-www-form-urlencoded) for documentation purposes. -// It is initialized as required with string as its DataType. -func FormParameter(name, description string) *Parameter { - p := &Parameter{&ParameterData{Name: name, Description: description, Required: false, DataType: "string"}} - p.beForm() - 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() - defer w.routesLock.Unlock() - builder.copyDefaults(w.produces, w.consumes) - w.routes = append(w.routes, builder.Build()) - return w -} - -// RemoveRoute removes the specified route, looks for something that matches 'path' and 'method' -func (w *WebService) RemoveRoute(path, method string) error { - if !w.dynamicRoutes { - return errors.New("dynamic routes are not enabled.") - } - w.routesLock.Lock() - defer w.routesLock.Unlock() - newRoutes := make([]Route, (len(w.routes) - 1)) - current := 0 - for ix := range w.routes { - if w.routes[ix].Method == method && w.routes[ix].Path == path { - continue - } - newRoutes[current] = w.routes[ix] - current++ - } - w.routes = newRoutes - return nil -} - -// Method creates a new RouteBuilder and initialize its http method -func (w *WebService) Method(httpMethod string) *RouteBuilder { - return new(RouteBuilder).typeNameHandler(w.typeNameHandleFunc).servicePath(w.rootPath).Method(httpMethod) -} - -// Produces specifies that this WebService can produce one or more MIME types. -// Http requests must have one of these values set for the Accept header. -func (w *WebService) Produces(contentTypes ...string) *WebService { - w.produces = contentTypes - return w -} - -// Consumes specifies that this WebService can consume one or more MIME types. -// Http requests must have one of these values set for the Content-Type header. -func (w *WebService) Consumes(accepts ...string) *WebService { - w.consumes = accepts - return w -} - -// Routes returns the Routes associated with this WebService -func (w *WebService) Routes() []Route { - if !w.dynamicRoutes { - return w.routes - } - // Make a copy of the array to prevent concurrency problems - w.routesLock.RLock() - defer w.routesLock.RUnlock() - result := make([]Route, len(w.routes)) - for ix := range w.routes { - result[ix] = w.routes[ix] - } - return result -} - -// RootPath returns the RootPath associated with this WebService. Default "/" -func (w *WebService) RootPath() string { - return w.rootPath -} - -// PathParameters return the path parameter names for (shared among its Routes) -func (w *WebService) PathParameters() []*Parameter { - return w.pathParameters -} - -// Filter adds a filter function to the chain of filters applicable to all its Routes -func (w *WebService) Filter(filter FilterFunction) *WebService { - w.filters = append(w.filters, filter) - return w -} - -// Doc is used to set the documentation of this service. -func (w *WebService) Doc(plainText string) *WebService { - w.documentation = plainText - return w -} - -// Documentation returns it. -func (w *WebService) Documentation() string { - return w.documentation -} - -/* - Convenience methods -*/ - -// HEAD is a shortcut for .Method("HEAD").Path(subPath) -func (w *WebService) HEAD(subPath string) *RouteBuilder { - return new(RouteBuilder).typeNameHandler(w.typeNameHandleFunc).servicePath(w.rootPath).Method("HEAD").Path(subPath) -} - -// GET is a shortcut for .Method("GET").Path(subPath) -func (w *WebService) GET(subPath string) *RouteBuilder { - return new(RouteBuilder).typeNameHandler(w.typeNameHandleFunc).servicePath(w.rootPath).Method("GET").Path(subPath) -} - -// POST is a shortcut for .Method("POST").Path(subPath) -func (w *WebService) POST(subPath string) *RouteBuilder { - return new(RouteBuilder).typeNameHandler(w.typeNameHandleFunc).servicePath(w.rootPath).Method("POST").Path(subPath) -} - -// PUT is a shortcut for .Method("PUT").Path(subPath) -func (w *WebService) PUT(subPath string) *RouteBuilder { - return new(RouteBuilder).typeNameHandler(w.typeNameHandleFunc).servicePath(w.rootPath).Method("PUT").Path(subPath) -} - -// PATCH is a shortcut for .Method("PATCH").Path(subPath) -func (w *WebService) PATCH(subPath string) *RouteBuilder { - return new(RouteBuilder).typeNameHandler(w.typeNameHandleFunc).servicePath(w.rootPath).Method("PATCH").Path(subPath) -} - -// DELETE is a shortcut for .Method("DELETE").Path(subPath) -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) -} diff --git a/vendor/github.com/emicklei/go-restful/web_service_container.go b/vendor/github.com/emicklei/go-restful/web_service_container.go deleted file mode 100644 index c9d31b06c..000000000 --- a/vendor/github.com/emicklei/go-restful/web_service_container.go +++ /dev/null @@ -1,39 +0,0 @@ -package restful - -// Copyright 2013 Ernest Micklei. All rights reserved. -// Use of this source code is governed by a license -// that can be found in the LICENSE file. - -import ( - "net/http" -) - -// DefaultContainer is a restful.Container that uses http.DefaultServeMux -var DefaultContainer *Container - -func init() { - DefaultContainer = NewContainer() - DefaultContainer.ServeMux = http.DefaultServeMux -} - -// If set the true then panics will not be caught to return HTTP 500. -// In that case, Route functions are responsible for handling any error situation. -// Default value is false = recover from panics. This has performance implications. -// OBSOLETE ; use restful.DefaultContainer.DoNotRecover(true) -var DoNotRecover = false - -// Add registers a new WebService add it to the DefaultContainer. -func Add(service *WebService) { - DefaultContainer.Add(service) -} - -// Filter appends a container FilterFunction from the DefaultContainer. -// These are called before dispatching a http.Request to a WebService. -func Filter(filter FilterFunction) { - DefaultContainer.Filter(filter) -} - -// RegisteredWebServices returns the collections of WebServices from the DefaultContainer -func RegisteredWebServices() []*WebService { - return DefaultContainer.RegisteredWebServices() -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 4d8ab2a4e..68e6e0817 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -261,14 +261,10 @@ github.com/elastic/go-elasticsearch/v7 github.com/elastic/go-elasticsearch/v7/esapi github.com/elastic/go-elasticsearch/v7/estransport github.com/elastic/go-elasticsearch/v7/internal/version -# github.com/emicklei/go-restful v2.16.0+incompatible => github.com/emicklei/go-restful v2.16.0+incompatible -## explicit -github.com/emicklei/go-restful -github.com/emicklei/go-restful/log -# github.com/emicklei/go-restful-openapi v1.4.1 => github.com/emicklei/go-restful-openapi v1.4.1 +# github.com/emicklei/go-restful-openapi/v2 v2.9.1 => github.com/emicklei/go-restful-openapi/v2 v2.9.2-0.20230507070325-d6acc08e570c ## explicit; go 1.13 -github.com/emicklei/go-restful-openapi -# github.com/emicklei/go-restful/v3 v3.10.1 => github.com/emicklei/go-restful/v3 v3.10.1 +github.com/emicklei/go-restful-openapi/v2 +# github.com/emicklei/go-restful/v3 v3.10.2 => github.com/emicklei/go-restful/v3 v3.10.2 ## explicit; go 1.13 github.com/emicklei/go-restful/v3 github.com/emicklei/go-restful/v3/log @@ -2644,9 +2640,8 @@ sigs.k8s.io/yaml # github.com/elastic/go-elasticsearch/v5 => github.com/elastic/go-elasticsearch/v5 v5.6.1 # github.com/elastic/go-elasticsearch/v6 => github.com/elastic/go-elasticsearch/v6 v6.8.2 # github.com/elastic/go-elasticsearch/v7 => github.com/elastic/go-elasticsearch/v7 v7.3.0 -# github.com/emicklei/go-restful => github.com/emicklei/go-restful v2.16.0+incompatible -# github.com/emicklei/go-restful-openapi => github.com/emicklei/go-restful-openapi v1.4.1 -# github.com/emicklei/go-restful/v3 => github.com/emicklei/go-restful/v3 v3.10.1 +# github.com/emicklei/go-restful-openapi/v2 => github.com/emicklei/go-restful-openapi/v2 v2.9.2-0.20230507070325-d6acc08e570c +# github.com/emicklei/go-restful/v3 => github.com/emicklei/go-restful/v3 v3.10.2 # github.com/emirpasic/gods => github.com/emirpasic/gods v1.12.0 # github.com/evanphx/json-patch => github.com/evanphx/json-patch v5.6.0+incompatible # github.com/evanphx/json-patch/v5 => github.com/evanphx/json-patch/v5 v5.6.0