planetscale 0.3.1 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +9 -1
- data/.github/workflows/gem-push.yml +9 -2
- data/.licenses/go/github.com/matoous/go-nanoid/v2.dep.yml +34 -0
- data/.licenses/go/github.com/planetscale/planetscale-go/planetscale.dep.yml +1 -1
- data/.licenses/go/github.com/planetscale/sql-proxy/proxy.dep.yml +1 -1
- data/.licenses/go/go.uber.org/zap/buffer.dep.yml +1 -1
- data/.licenses/go/go.uber.org/zap/internal/bufferpool.dep.yml +1 -1
- data/.licenses/go/go.uber.org/zap/internal/color.dep.yml +1 -1
- data/.licenses/go/go.uber.org/zap/internal/exit.dep.yml +1 -1
- data/.licenses/go/go.uber.org/zap/zapcore.dep.yml +1 -1
- data/.licenses/go/go.uber.org/zap.dep.yml +1 -1
- data/README.md +2 -0
- data/controller.go +21 -36
- data/go.mod +4 -3
- data/go.sum +32 -18
- data/lib/planetscale/version.rb +1 -1
- data/lib/planetscale.rb +2 -3
- data/planetscale.gemspec +1 -1
- data/proxy/planetscale-darwin.h +1 -1
- data/proxy/planetscale-darwin.so +0 -0
- data/proxy/planetscale-linux.h +1 -1
- data/proxy/planetscale-linux.so +0 -0
- data/proxy.go +1 -5
- metadata +3 -345
- data/vendor/github.com/armon/circbuf/.gitignore +0 -22
- data/vendor/github.com/armon/circbuf/LICENSE +0 -20
- data/vendor/github.com/armon/circbuf/README.md +0 -28
- data/vendor/github.com/armon/circbuf/circbuf.go +0 -92
- data/vendor/github.com/armon/circbuf/go.mod +0 -1
- data/vendor/github.com/golang/protobuf/AUTHORS +0 -3
- data/vendor/github.com/golang/protobuf/CONTRIBUTORS +0 -3
- data/vendor/github.com/golang/protobuf/LICENSE +0 -28
- data/vendor/github.com/golang/protobuf/proto/buffer.go +0 -324
- data/vendor/github.com/golang/protobuf/proto/defaults.go +0 -63
- data/vendor/github.com/golang/protobuf/proto/deprecated.go +0 -113
- data/vendor/github.com/golang/protobuf/proto/discard.go +0 -58
- data/vendor/github.com/golang/protobuf/proto/extensions.go +0 -356
- data/vendor/github.com/golang/protobuf/proto/properties.go +0 -306
- data/vendor/github.com/golang/protobuf/proto/proto.go +0 -167
- data/vendor/github.com/golang/protobuf/proto/registry.go +0 -317
- data/vendor/github.com/golang/protobuf/proto/text_decode.go +0 -801
- data/vendor/github.com/golang/protobuf/proto/text_encode.go +0 -560
- data/vendor/github.com/golang/protobuf/proto/wire.go +0 -78
- data/vendor/github.com/golang/protobuf/proto/wrappers.go +0 -34
- data/vendor/github.com/gorilla/mux/AUTHORS +0 -8
- data/vendor/github.com/gorilla/mux/LICENSE +0 -27
- data/vendor/github.com/gorilla/mux/README.md +0 -805
- data/vendor/github.com/gorilla/mux/doc.go +0 -306
- data/vendor/github.com/gorilla/mux/go.mod +0 -3
- data/vendor/github.com/gorilla/mux/middleware.go +0 -74
- data/vendor/github.com/gorilla/mux/mux.go +0 -606
- data/vendor/github.com/gorilla/mux/regexp.go +0 -388
- data/vendor/github.com/gorilla/mux/route.go +0 -736
- data/vendor/github.com/gorilla/mux/test_helpers.go +0 -19
- data/vendor/github.com/hashicorp/go-cleanhttp/LICENSE +0 -363
- data/vendor/github.com/hashicorp/go-cleanhttp/README.md +0 -30
- data/vendor/github.com/hashicorp/go-cleanhttp/cleanhttp.go +0 -58
- data/vendor/github.com/hashicorp/go-cleanhttp/doc.go +0 -20
- data/vendor/github.com/hashicorp/go-cleanhttp/go.mod +0 -3
- data/vendor/github.com/hashicorp/go-cleanhttp/handlers.go +0 -48
- data/vendor/github.com/mitchellh/go-homedir/LICENSE +0 -21
- data/vendor/github.com/mitchellh/go-homedir/README.md +0 -14
- data/vendor/github.com/mitchellh/go-homedir/go.mod +0 -1
- data/vendor/github.com/mitchellh/go-homedir/homedir.go +0 -167
- data/vendor/github.com/pkg/errors/.gitignore +0 -24
- data/vendor/github.com/pkg/errors/.travis.yml +0 -10
- data/vendor/github.com/pkg/errors/LICENSE +0 -23
- data/vendor/github.com/pkg/errors/Makefile +0 -44
- data/vendor/github.com/pkg/errors/README.md +0 -59
- data/vendor/github.com/pkg/errors/appveyor.yml +0 -32
- data/vendor/github.com/pkg/errors/errors.go +0 -288
- data/vendor/github.com/pkg/errors/go113.go +0 -38
- data/vendor/github.com/pkg/errors/stack.go +0 -177
- data/vendor/github.com/planetscale/planetscale-go/LICENSE +0 -202
- data/vendor/github.com/planetscale/planetscale-go/planetscale/audit_logs.go +0 -136
- data/vendor/github.com/planetscale/planetscale-go/planetscale/backups.go +0 -139
- data/vendor/github.com/planetscale/planetscale-go/planetscale/branches.go +0 -252
- data/vendor/github.com/planetscale/planetscale-go/planetscale/certs.go +0 -166
- data/vendor/github.com/planetscale/planetscale-go/planetscale/client.go +0 -312
- data/vendor/github.com/planetscale/planetscale-go/planetscale/databases.go +0 -133
- data/vendor/github.com/planetscale/planetscale-go/planetscale/deploy_requests.go +0 -368
- data/vendor/github.com/planetscale/planetscale-go/planetscale/organizations.go +0 -103
- data/vendor/github.com/planetscale/planetscale-go/planetscale/regions.go +0 -52
- data/vendor/github.com/planetscale/planetscale-go/planetscale/service_tokens.go +0 -163
- data/vendor/github.com/planetscale/sql-proxy/LICENSE +0 -202
- data/vendor/github.com/planetscale/sql-proxy/proxy/client.go +0 -476
- data/vendor/github.com/planetscale/sql-proxy/proxy/tls_cache.go +0 -73
- data/vendor/go.uber.org/atomic/.codecov.yml +0 -19
- data/vendor/go.uber.org/atomic/.gitignore +0 -12
- data/vendor/go.uber.org/atomic/.travis.yml +0 -27
- data/vendor/go.uber.org/atomic/CHANGELOG.md +0 -76
- data/vendor/go.uber.org/atomic/LICENSE.txt +0 -19
- data/vendor/go.uber.org/atomic/Makefile +0 -78
- data/vendor/go.uber.org/atomic/README.md +0 -63
- data/vendor/go.uber.org/atomic/bool.go +0 -81
- data/vendor/go.uber.org/atomic/bool_ext.go +0 -53
- data/vendor/go.uber.org/atomic/doc.go +0 -23
- data/vendor/go.uber.org/atomic/duration.go +0 -82
- data/vendor/go.uber.org/atomic/duration_ext.go +0 -40
- data/vendor/go.uber.org/atomic/error.go +0 -51
- data/vendor/go.uber.org/atomic/error_ext.go +0 -39
- data/vendor/go.uber.org/atomic/float64.go +0 -76
- data/vendor/go.uber.org/atomic/float64_ext.go +0 -47
- data/vendor/go.uber.org/atomic/gen.go +0 -26
- data/vendor/go.uber.org/atomic/go.mod +0 -8
- data/vendor/go.uber.org/atomic/go.sum +0 -9
- data/vendor/go.uber.org/atomic/int32.go +0 -102
- data/vendor/go.uber.org/atomic/int64.go +0 -102
- data/vendor/go.uber.org/atomic/nocmp.go +0 -35
- data/vendor/go.uber.org/atomic/string.go +0 -54
- data/vendor/go.uber.org/atomic/string_ext.go +0 -43
- data/vendor/go.uber.org/atomic/uint32.go +0 -102
- data/vendor/go.uber.org/atomic/uint64.go +0 -102
- data/vendor/go.uber.org/atomic/value.go +0 -31
- data/vendor/go.uber.org/multierr/.codecov.yml +0 -15
- data/vendor/go.uber.org/multierr/.gitignore +0 -4
- data/vendor/go.uber.org/multierr/.travis.yml +0 -23
- data/vendor/go.uber.org/multierr/CHANGELOG.md +0 -60
- data/vendor/go.uber.org/multierr/LICENSE.txt +0 -19
- data/vendor/go.uber.org/multierr/Makefile +0 -42
- data/vendor/go.uber.org/multierr/README.md +0 -23
- data/vendor/go.uber.org/multierr/error.go +0 -449
- data/vendor/go.uber.org/multierr/glide.yaml +0 -8
- data/vendor/go.uber.org/multierr/go.mod +0 -8
- data/vendor/go.uber.org/multierr/go.sum +0 -11
- data/vendor/go.uber.org/multierr/go113.go +0 -52
- data/vendor/go.uber.org/zap/.codecov.yml +0 -17
- data/vendor/go.uber.org/zap/.gitignore +0 -32
- data/vendor/go.uber.org/zap/.readme.tmpl +0 -109
- data/vendor/go.uber.org/zap/CHANGELOG.md +0 -492
- data/vendor/go.uber.org/zap/CODE_OF_CONDUCT.md +0 -75
- data/vendor/go.uber.org/zap/CONTRIBUTING.md +0 -75
- data/vendor/go.uber.org/zap/FAQ.md +0 -164
- data/vendor/go.uber.org/zap/LICENSE.txt +0 -19
- data/vendor/go.uber.org/zap/Makefile +0 -73
- data/vendor/go.uber.org/zap/README.md +0 -134
- data/vendor/go.uber.org/zap/array.go +0 -320
- data/vendor/go.uber.org/zap/buffer/buffer.go +0 -141
- data/vendor/go.uber.org/zap/buffer/pool.go +0 -49
- data/vendor/go.uber.org/zap/checklicense.sh +0 -17
- data/vendor/go.uber.org/zap/config.go +0 -264
- data/vendor/go.uber.org/zap/doc.go +0 -113
- data/vendor/go.uber.org/zap/encoder.go +0 -79
- data/vendor/go.uber.org/zap/error.go +0 -80
- data/vendor/go.uber.org/zap/field.go +0 -549
- data/vendor/go.uber.org/zap/flag.go +0 -39
- data/vendor/go.uber.org/zap/glide.yaml +0 -34
- data/vendor/go.uber.org/zap/global.go +0 -168
- data/vendor/go.uber.org/zap/global_go112.go +0 -26
- data/vendor/go.uber.org/zap/global_prego112.go +0 -26
- data/vendor/go.uber.org/zap/go.mod +0 -14
- data/vendor/go.uber.org/zap/go.sum +0 -54
- data/vendor/go.uber.org/zap/http_handler.go +0 -132
- data/vendor/go.uber.org/zap/internal/bufferpool/bufferpool.go +0 -31
- data/vendor/go.uber.org/zap/internal/color/color.go +0 -44
- data/vendor/go.uber.org/zap/internal/exit/exit.go +0 -64
- data/vendor/go.uber.org/zap/level.go +0 -132
- data/vendor/go.uber.org/zap/logger.go +0 -348
- data/vendor/go.uber.org/zap/options.go +0 -148
- data/vendor/go.uber.org/zap/sink.go +0 -161
- data/vendor/go.uber.org/zap/stacktrace.go +0 -85
- data/vendor/go.uber.org/zap/sugar.go +0 -315
- data/vendor/go.uber.org/zap/time.go +0 -27
- data/vendor/go.uber.org/zap/writer.go +0 -99
- data/vendor/go.uber.org/zap/zapcore/buffered_write_syncer.go +0 -188
- data/vendor/go.uber.org/zap/zapcore/clock.go +0 -50
- data/vendor/go.uber.org/zap/zapcore/console_encoder.go +0 -161
- data/vendor/go.uber.org/zap/zapcore/core.go +0 -113
- data/vendor/go.uber.org/zap/zapcore/doc.go +0 -24
- data/vendor/go.uber.org/zap/zapcore/encoder.go +0 -443
- data/vendor/go.uber.org/zap/zapcore/entry.go +0 -264
- data/vendor/go.uber.org/zap/zapcore/error.go +0 -132
- data/vendor/go.uber.org/zap/zapcore/field.go +0 -233
- data/vendor/go.uber.org/zap/zapcore/hook.go +0 -68
- data/vendor/go.uber.org/zap/zapcore/increase_level.go +0 -66
- data/vendor/go.uber.org/zap/zapcore/json_encoder.go +0 -534
- data/vendor/go.uber.org/zap/zapcore/level.go +0 -175
- data/vendor/go.uber.org/zap/zapcore/level_strings.go +0 -46
- data/vendor/go.uber.org/zap/zapcore/marshaler.go +0 -61
- data/vendor/go.uber.org/zap/zapcore/memory_encoder.go +0 -179
- data/vendor/go.uber.org/zap/zapcore/sampler.go +0 -208
- data/vendor/go.uber.org/zap/zapcore/tee.go +0 -81
- data/vendor/go.uber.org/zap/zapcore/write_syncer.go +0 -122
- data/vendor/golang.org/x/net/AUTHORS +0 -3
- data/vendor/golang.org/x/net/CONTRIBUTORS +0 -3
- data/vendor/golang.org/x/net/LICENSE +0 -27
- data/vendor/golang.org/x/net/PATENTS +0 -22
- data/vendor/golang.org/x/net/context/context.go +0 -56
- data/vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go +0 -71
- data/vendor/golang.org/x/net/context/go17.go +0 -73
- data/vendor/golang.org/x/net/context/go19.go +0 -21
- data/vendor/golang.org/x/net/context/pre_go17.go +0 -301
- data/vendor/golang.org/x/net/context/pre_go19.go +0 -110
- data/vendor/golang.org/x/oauth2/.travis.yml +0 -13
- data/vendor/golang.org/x/oauth2/AUTHORS +0 -3
- data/vendor/golang.org/x/oauth2/CONTRIBUTING.md +0 -26
- data/vendor/golang.org/x/oauth2/CONTRIBUTORS +0 -3
- data/vendor/golang.org/x/oauth2/LICENSE +0 -27
- data/vendor/golang.org/x/oauth2/README.md +0 -36
- data/vendor/golang.org/x/oauth2/go.mod +0 -9
- data/vendor/golang.org/x/oauth2/go.sum +0 -361
- data/vendor/golang.org/x/oauth2/internal/client_appengine.go +0 -14
- data/vendor/golang.org/x/oauth2/internal/doc.go +0 -6
- data/vendor/golang.org/x/oauth2/internal/oauth2.go +0 -37
- data/vendor/golang.org/x/oauth2/internal/token.go +0 -294
- data/vendor/golang.org/x/oauth2/internal/transport.go +0 -33
- data/vendor/golang.org/x/oauth2/oauth2.go +0 -381
- data/vendor/golang.org/x/oauth2/token.go +0 -178
- data/vendor/golang.org/x/oauth2/transport.go +0 -89
- data/vendor/google.golang.org/appengine/LICENSE +0 -202
- data/vendor/google.golang.org/appengine/internal/api.go +0 -678
- data/vendor/google.golang.org/appengine/internal/api_classic.go +0 -169
- data/vendor/google.golang.org/appengine/internal/api_common.go +0 -123
- data/vendor/google.golang.org/appengine/internal/app_id.go +0 -28
- data/vendor/google.golang.org/appengine/internal/base/api_base.pb.go +0 -308
- data/vendor/google.golang.org/appengine/internal/base/api_base.proto +0 -33
- data/vendor/google.golang.org/appengine/internal/datastore/datastore_v3.pb.go +0 -4367
- data/vendor/google.golang.org/appengine/internal/datastore/datastore_v3.proto +0 -551
- data/vendor/google.golang.org/appengine/internal/identity.go +0 -55
- data/vendor/google.golang.org/appengine/internal/identity_classic.go +0 -61
- data/vendor/google.golang.org/appengine/internal/identity_flex.go +0 -11
- data/vendor/google.golang.org/appengine/internal/identity_vm.go +0 -134
- data/vendor/google.golang.org/appengine/internal/internal.go +0 -110
- data/vendor/google.golang.org/appengine/internal/log/log_service.pb.go +0 -1313
- data/vendor/google.golang.org/appengine/internal/log/log_service.proto +0 -150
- data/vendor/google.golang.org/appengine/internal/main.go +0 -16
- data/vendor/google.golang.org/appengine/internal/main_common.go +0 -7
- data/vendor/google.golang.org/appengine/internal/main_vm.go +0 -69
- data/vendor/google.golang.org/appengine/internal/metadata.go +0 -60
- data/vendor/google.golang.org/appengine/internal/net.go +0 -56
- data/vendor/google.golang.org/appengine/internal/regen.sh +0 -40
- data/vendor/google.golang.org/appengine/internal/remote_api/remote_api.pb.go +0 -361
- data/vendor/google.golang.org/appengine/internal/remote_api/remote_api.proto +0 -44
- data/vendor/google.golang.org/appengine/internal/transaction.go +0 -115
- data/vendor/google.golang.org/appengine/internal/urlfetch/urlfetch_service.pb.go +0 -527
- data/vendor/google.golang.org/appengine/internal/urlfetch/urlfetch_service.proto +0 -64
- data/vendor/google.golang.org/appengine/urlfetch/urlfetch.go +0 -210
- data/vendor/google.golang.org/protobuf/AUTHORS +0 -3
- data/vendor/google.golang.org/protobuf/CONTRIBUTORS +0 -3
- data/vendor/google.golang.org/protobuf/LICENSE +0 -27
- data/vendor/google.golang.org/protobuf/PATENTS +0 -22
- data/vendor/google.golang.org/protobuf/encoding/prototext/decode.go +0 -773
- data/vendor/google.golang.org/protobuf/encoding/prototext/doc.go +0 -7
- data/vendor/google.golang.org/protobuf/encoding/prototext/encode.go +0 -371
- data/vendor/google.golang.org/protobuf/encoding/protowire/wire.go +0 -538
- data/vendor/google.golang.org/protobuf/internal/descfmt/stringer.go +0 -318
- data/vendor/google.golang.org/protobuf/internal/descopts/options.go +0 -29
- data/vendor/google.golang.org/protobuf/internal/detrand/rand.go +0 -69
- data/vendor/google.golang.org/protobuf/internal/encoding/defval/default.go +0 -213
- data/vendor/google.golang.org/protobuf/internal/encoding/messageset/messageset.go +0 -241
- data/vendor/google.golang.org/protobuf/internal/encoding/tag/tag.go +0 -207
- data/vendor/google.golang.org/protobuf/internal/encoding/text/decode.go +0 -665
- data/vendor/google.golang.org/protobuf/internal/encoding/text/decode_number.go +0 -190
- data/vendor/google.golang.org/protobuf/internal/encoding/text/decode_string.go +0 -161
- data/vendor/google.golang.org/protobuf/internal/encoding/text/decode_token.go +0 -373
- data/vendor/google.golang.org/protobuf/internal/encoding/text/doc.go +0 -29
- data/vendor/google.golang.org/protobuf/internal/encoding/text/encode.go +0 -265
- data/vendor/google.golang.org/protobuf/internal/errors/errors.go +0 -89
- data/vendor/google.golang.org/protobuf/internal/errors/is_go112.go +0 -39
- data/vendor/google.golang.org/protobuf/internal/errors/is_go113.go +0 -12
- data/vendor/google.golang.org/protobuf/internal/filedesc/build.go +0 -158
- data/vendor/google.golang.org/protobuf/internal/filedesc/desc.go +0 -631
- data/vendor/google.golang.org/protobuf/internal/filedesc/desc_init.go +0 -471
- data/vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go +0 -704
- data/vendor/google.golang.org/protobuf/internal/filedesc/desc_list.go +0 -450
- data/vendor/google.golang.org/protobuf/internal/filedesc/desc_list_gen.go +0 -356
- data/vendor/google.golang.org/protobuf/internal/filedesc/placeholder.go +0 -107
- data/vendor/google.golang.org/protobuf/internal/filetype/build.go +0 -297
- data/vendor/google.golang.org/protobuf/internal/flags/flags.go +0 -24
- data/vendor/google.golang.org/protobuf/internal/flags/proto_legacy_disable.go +0 -9
- data/vendor/google.golang.org/protobuf/internal/flags/proto_legacy_enable.go +0 -9
- data/vendor/google.golang.org/protobuf/internal/genid/any_gen.go +0 -34
- data/vendor/google.golang.org/protobuf/internal/genid/api_gen.go +0 -106
- data/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go +0 -829
- data/vendor/google.golang.org/protobuf/internal/genid/doc.go +0 -11
- data/vendor/google.golang.org/protobuf/internal/genid/duration_gen.go +0 -34
- data/vendor/google.golang.org/protobuf/internal/genid/empty_gen.go +0 -19
- data/vendor/google.golang.org/protobuf/internal/genid/field_mask_gen.go +0 -31
- data/vendor/google.golang.org/protobuf/internal/genid/goname.go +0 -25
- data/vendor/google.golang.org/protobuf/internal/genid/map_entry.go +0 -16
- data/vendor/google.golang.org/protobuf/internal/genid/source_context_gen.go +0 -31
- data/vendor/google.golang.org/protobuf/internal/genid/struct_gen.go +0 -116
- data/vendor/google.golang.org/protobuf/internal/genid/timestamp_gen.go +0 -34
- data/vendor/google.golang.org/protobuf/internal/genid/type_gen.go +0 -184
- data/vendor/google.golang.org/protobuf/internal/genid/wrappers.go +0 -13
- data/vendor/google.golang.org/protobuf/internal/genid/wrappers_gen.go +0 -175
- data/vendor/google.golang.org/protobuf/internal/impl/api_export.go +0 -177
- data/vendor/google.golang.org/protobuf/internal/impl/checkinit.go +0 -141
- data/vendor/google.golang.org/protobuf/internal/impl/codec_extension.go +0 -223
- data/vendor/google.golang.org/protobuf/internal/impl/codec_field.go +0 -830
- data/vendor/google.golang.org/protobuf/internal/impl/codec_gen.go +0 -5637
- data/vendor/google.golang.org/protobuf/internal/impl/codec_map.go +0 -388
- data/vendor/google.golang.org/protobuf/internal/impl/codec_map_go111.go +0 -37
- data/vendor/google.golang.org/protobuf/internal/impl/codec_map_go112.go +0 -11
- data/vendor/google.golang.org/protobuf/internal/impl/codec_message.go +0 -217
- data/vendor/google.golang.org/protobuf/internal/impl/codec_messageset.go +0 -123
- data/vendor/google.golang.org/protobuf/internal/impl/codec_reflect.go +0 -209
- data/vendor/google.golang.org/protobuf/internal/impl/codec_tables.go +0 -557
- data/vendor/google.golang.org/protobuf/internal/impl/codec_unsafe.go +0 -17
- data/vendor/google.golang.org/protobuf/internal/impl/convert.go +0 -496
- data/vendor/google.golang.org/protobuf/internal/impl/convert_list.go +0 -141
- data/vendor/google.golang.org/protobuf/internal/impl/convert_map.go +0 -121
- data/vendor/google.golang.org/protobuf/internal/impl/decode.go +0 -276
- data/vendor/google.golang.org/protobuf/internal/impl/encode.go +0 -201
- data/vendor/google.golang.org/protobuf/internal/impl/enum.go +0 -21
- data/vendor/google.golang.org/protobuf/internal/impl/extension.go +0 -156
- data/vendor/google.golang.org/protobuf/internal/impl/legacy_enum.go +0 -219
- data/vendor/google.golang.org/protobuf/internal/impl/legacy_export.go +0 -92
- data/vendor/google.golang.org/protobuf/internal/impl/legacy_extension.go +0 -176
- data/vendor/google.golang.org/protobuf/internal/impl/legacy_file.go +0 -81
- data/vendor/google.golang.org/protobuf/internal/impl/legacy_message.go +0 -558
- data/vendor/google.golang.org/protobuf/internal/impl/merge.go +0 -176
- data/vendor/google.golang.org/protobuf/internal/impl/merge_gen.go +0 -209
- data/vendor/google.golang.org/protobuf/internal/impl/message.go +0 -276
- data/vendor/google.golang.org/protobuf/internal/impl/message_reflect.go +0 -465
- data/vendor/google.golang.org/protobuf/internal/impl/message_reflect_field.go +0 -543
- data/vendor/google.golang.org/protobuf/internal/impl/message_reflect_gen.go +0 -249
- data/vendor/google.golang.org/protobuf/internal/impl/pointer_reflect.go +0 -178
- data/vendor/google.golang.org/protobuf/internal/impl/pointer_unsafe.go +0 -174
- data/vendor/google.golang.org/protobuf/internal/impl/validate.go +0 -576
- data/vendor/google.golang.org/protobuf/internal/impl/weak.go +0 -74
- data/vendor/google.golang.org/protobuf/internal/order/order.go +0 -89
- data/vendor/google.golang.org/protobuf/internal/order/range.go +0 -115
- data/vendor/google.golang.org/protobuf/internal/pragma/pragma.go +0 -29
- data/vendor/google.golang.org/protobuf/internal/set/ints.go +0 -58
- data/vendor/google.golang.org/protobuf/internal/strs/strings.go +0 -196
- data/vendor/google.golang.org/protobuf/internal/strs/strings_pure.go +0 -27
- data/vendor/google.golang.org/protobuf/internal/strs/strings_unsafe.go +0 -94
- data/vendor/google.golang.org/protobuf/internal/version/version.go +0 -79
- data/vendor/google.golang.org/protobuf/proto/checkinit.go +0 -71
- data/vendor/google.golang.org/protobuf/proto/decode.go +0 -278
- data/vendor/google.golang.org/protobuf/proto/decode_gen.go +0 -603
- data/vendor/google.golang.org/protobuf/proto/doc.go +0 -94
- data/vendor/google.golang.org/protobuf/proto/encode.go +0 -319
- data/vendor/google.golang.org/protobuf/proto/encode_gen.go +0 -97
- data/vendor/google.golang.org/protobuf/proto/equal.go +0 -167
- data/vendor/google.golang.org/protobuf/proto/extension.go +0 -92
- data/vendor/google.golang.org/protobuf/proto/merge.go +0 -139
- data/vendor/google.golang.org/protobuf/proto/messageset.go +0 -93
- data/vendor/google.golang.org/protobuf/proto/proto.go +0 -43
- data/vendor/google.golang.org/protobuf/proto/proto_methods.go +0 -19
- data/vendor/google.golang.org/protobuf/proto/proto_reflect.go +0 -19
- data/vendor/google.golang.org/protobuf/proto/reset.go +0 -43
- data/vendor/google.golang.org/protobuf/proto/size.go +0 -97
- data/vendor/google.golang.org/protobuf/proto/size_gen.go +0 -55
- data/vendor/google.golang.org/protobuf/proto/wrappers.go +0 -29
- data/vendor/google.golang.org/protobuf/reflect/protodesc/desc.go +0 -276
- data/vendor/google.golang.org/protobuf/reflect/protodesc/desc_init.go +0 -248
- data/vendor/google.golang.org/protobuf/reflect/protodesc/desc_resolve.go +0 -286
- data/vendor/google.golang.org/protobuf/reflect/protodesc/desc_validate.go +0 -374
- data/vendor/google.golang.org/protobuf/reflect/protodesc/proto.go +0 -252
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/methods.go +0 -77
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/proto.go +0 -504
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/source.go +0 -128
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go +0 -461
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/type.go +0 -665
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/value.go +0 -285
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/value_pure.go +0 -59
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/value_union.go +0 -411
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/value_unsafe.go +0 -98
- data/vendor/google.golang.org/protobuf/reflect/protoregistry/registry.go +0 -869
- data/vendor/google.golang.org/protobuf/runtime/protoiface/legacy.go +0 -15
- data/vendor/google.golang.org/protobuf/runtime/protoiface/methods.go +0 -167
- data/vendor/google.golang.org/protobuf/runtime/protoimpl/impl.go +0 -44
- data/vendor/google.golang.org/protobuf/runtime/protoimpl/version.go +0 -56
- data/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go +0 -4039
- data/vendor/modules.txt +0 -79
@@ -1,736 +0,0 @@
|
|
1
|
-
// Copyright 2012 The Gorilla Authors. All rights reserved.
|
2
|
-
// Use of this source code is governed by a BSD-style
|
3
|
-
// license that can be found in the LICENSE file.
|
4
|
-
|
5
|
-
package mux
|
6
|
-
|
7
|
-
import (
|
8
|
-
"errors"
|
9
|
-
"fmt"
|
10
|
-
"net/http"
|
11
|
-
"net/url"
|
12
|
-
"regexp"
|
13
|
-
"strings"
|
14
|
-
)
|
15
|
-
|
16
|
-
// Route stores information to match a request and build URLs.
|
17
|
-
type Route struct {
|
18
|
-
// Request handler for the route.
|
19
|
-
handler http.Handler
|
20
|
-
// If true, this route never matches: it is only used to build URLs.
|
21
|
-
buildOnly bool
|
22
|
-
// The name used to build URLs.
|
23
|
-
name string
|
24
|
-
// Error resulted from building a route.
|
25
|
-
err error
|
26
|
-
|
27
|
-
// "global" reference to all named routes
|
28
|
-
namedRoutes map[string]*Route
|
29
|
-
|
30
|
-
// config possibly passed in from `Router`
|
31
|
-
routeConf
|
32
|
-
}
|
33
|
-
|
34
|
-
// SkipClean reports whether path cleaning is enabled for this route via
|
35
|
-
// Router.SkipClean.
|
36
|
-
func (r *Route) SkipClean() bool {
|
37
|
-
return r.skipClean
|
38
|
-
}
|
39
|
-
|
40
|
-
// Match matches the route against the request.
|
41
|
-
func (r *Route) Match(req *http.Request, match *RouteMatch) bool {
|
42
|
-
if r.buildOnly || r.err != nil {
|
43
|
-
return false
|
44
|
-
}
|
45
|
-
|
46
|
-
var matchErr error
|
47
|
-
|
48
|
-
// Match everything.
|
49
|
-
for _, m := range r.matchers {
|
50
|
-
if matched := m.Match(req, match); !matched {
|
51
|
-
if _, ok := m.(methodMatcher); ok {
|
52
|
-
matchErr = ErrMethodMismatch
|
53
|
-
continue
|
54
|
-
}
|
55
|
-
|
56
|
-
// Ignore ErrNotFound errors. These errors arise from match call
|
57
|
-
// to Subrouters.
|
58
|
-
//
|
59
|
-
// This prevents subsequent matching subrouters from failing to
|
60
|
-
// run middleware. If not ignored, the middleware would see a
|
61
|
-
// non-nil MatchErr and be skipped, even when there was a
|
62
|
-
// matching route.
|
63
|
-
if match.MatchErr == ErrNotFound {
|
64
|
-
match.MatchErr = nil
|
65
|
-
}
|
66
|
-
|
67
|
-
matchErr = nil
|
68
|
-
return false
|
69
|
-
}
|
70
|
-
}
|
71
|
-
|
72
|
-
if matchErr != nil {
|
73
|
-
match.MatchErr = matchErr
|
74
|
-
return false
|
75
|
-
}
|
76
|
-
|
77
|
-
if match.MatchErr == ErrMethodMismatch && r.handler != nil {
|
78
|
-
// We found a route which matches request method, clear MatchErr
|
79
|
-
match.MatchErr = nil
|
80
|
-
// Then override the mis-matched handler
|
81
|
-
match.Handler = r.handler
|
82
|
-
}
|
83
|
-
|
84
|
-
// Yay, we have a match. Let's collect some info about it.
|
85
|
-
if match.Route == nil {
|
86
|
-
match.Route = r
|
87
|
-
}
|
88
|
-
if match.Handler == nil {
|
89
|
-
match.Handler = r.handler
|
90
|
-
}
|
91
|
-
if match.Vars == nil {
|
92
|
-
match.Vars = make(map[string]string)
|
93
|
-
}
|
94
|
-
|
95
|
-
// Set variables.
|
96
|
-
r.regexp.setMatch(req, match, r)
|
97
|
-
return true
|
98
|
-
}
|
99
|
-
|
100
|
-
// ----------------------------------------------------------------------------
|
101
|
-
// Route attributes
|
102
|
-
// ----------------------------------------------------------------------------
|
103
|
-
|
104
|
-
// GetError returns an error resulted from building the route, if any.
|
105
|
-
func (r *Route) GetError() error {
|
106
|
-
return r.err
|
107
|
-
}
|
108
|
-
|
109
|
-
// BuildOnly sets the route to never match: it is only used to build URLs.
|
110
|
-
func (r *Route) BuildOnly() *Route {
|
111
|
-
r.buildOnly = true
|
112
|
-
return r
|
113
|
-
}
|
114
|
-
|
115
|
-
// Handler --------------------------------------------------------------------
|
116
|
-
|
117
|
-
// Handler sets a handler for the route.
|
118
|
-
func (r *Route) Handler(handler http.Handler) *Route {
|
119
|
-
if r.err == nil {
|
120
|
-
r.handler = handler
|
121
|
-
}
|
122
|
-
return r
|
123
|
-
}
|
124
|
-
|
125
|
-
// HandlerFunc sets a handler function for the route.
|
126
|
-
func (r *Route) HandlerFunc(f func(http.ResponseWriter, *http.Request)) *Route {
|
127
|
-
return r.Handler(http.HandlerFunc(f))
|
128
|
-
}
|
129
|
-
|
130
|
-
// GetHandler returns the handler for the route, if any.
|
131
|
-
func (r *Route) GetHandler() http.Handler {
|
132
|
-
return r.handler
|
133
|
-
}
|
134
|
-
|
135
|
-
// Name -----------------------------------------------------------------------
|
136
|
-
|
137
|
-
// Name sets the name for the route, used to build URLs.
|
138
|
-
// It is an error to call Name more than once on a route.
|
139
|
-
func (r *Route) Name(name string) *Route {
|
140
|
-
if r.name != "" {
|
141
|
-
r.err = fmt.Errorf("mux: route already has name %q, can't set %q",
|
142
|
-
r.name, name)
|
143
|
-
}
|
144
|
-
if r.err == nil {
|
145
|
-
r.name = name
|
146
|
-
r.namedRoutes[name] = r
|
147
|
-
}
|
148
|
-
return r
|
149
|
-
}
|
150
|
-
|
151
|
-
// GetName returns the name for the route, if any.
|
152
|
-
func (r *Route) GetName() string {
|
153
|
-
return r.name
|
154
|
-
}
|
155
|
-
|
156
|
-
// ----------------------------------------------------------------------------
|
157
|
-
// Matchers
|
158
|
-
// ----------------------------------------------------------------------------
|
159
|
-
|
160
|
-
// matcher types try to match a request.
|
161
|
-
type matcher interface {
|
162
|
-
Match(*http.Request, *RouteMatch) bool
|
163
|
-
}
|
164
|
-
|
165
|
-
// addMatcher adds a matcher to the route.
|
166
|
-
func (r *Route) addMatcher(m matcher) *Route {
|
167
|
-
if r.err == nil {
|
168
|
-
r.matchers = append(r.matchers, m)
|
169
|
-
}
|
170
|
-
return r
|
171
|
-
}
|
172
|
-
|
173
|
-
// addRegexpMatcher adds a host or path matcher and builder to a route.
|
174
|
-
func (r *Route) addRegexpMatcher(tpl string, typ regexpType) error {
|
175
|
-
if r.err != nil {
|
176
|
-
return r.err
|
177
|
-
}
|
178
|
-
if typ == regexpTypePath || typ == regexpTypePrefix {
|
179
|
-
if len(tpl) > 0 && tpl[0] != '/' {
|
180
|
-
return fmt.Errorf("mux: path must start with a slash, got %q", tpl)
|
181
|
-
}
|
182
|
-
if r.regexp.path != nil {
|
183
|
-
tpl = strings.TrimRight(r.regexp.path.template, "/") + tpl
|
184
|
-
}
|
185
|
-
}
|
186
|
-
rr, err := newRouteRegexp(tpl, typ, routeRegexpOptions{
|
187
|
-
strictSlash: r.strictSlash,
|
188
|
-
useEncodedPath: r.useEncodedPath,
|
189
|
-
})
|
190
|
-
if err != nil {
|
191
|
-
return err
|
192
|
-
}
|
193
|
-
for _, q := range r.regexp.queries {
|
194
|
-
if err = uniqueVars(rr.varsN, q.varsN); err != nil {
|
195
|
-
return err
|
196
|
-
}
|
197
|
-
}
|
198
|
-
if typ == regexpTypeHost {
|
199
|
-
if r.regexp.path != nil {
|
200
|
-
if err = uniqueVars(rr.varsN, r.regexp.path.varsN); err != nil {
|
201
|
-
return err
|
202
|
-
}
|
203
|
-
}
|
204
|
-
r.regexp.host = rr
|
205
|
-
} else {
|
206
|
-
if r.regexp.host != nil {
|
207
|
-
if err = uniqueVars(rr.varsN, r.regexp.host.varsN); err != nil {
|
208
|
-
return err
|
209
|
-
}
|
210
|
-
}
|
211
|
-
if typ == regexpTypeQuery {
|
212
|
-
r.regexp.queries = append(r.regexp.queries, rr)
|
213
|
-
} else {
|
214
|
-
r.regexp.path = rr
|
215
|
-
}
|
216
|
-
}
|
217
|
-
r.addMatcher(rr)
|
218
|
-
return nil
|
219
|
-
}
|
220
|
-
|
221
|
-
// Headers --------------------------------------------------------------------
|
222
|
-
|
223
|
-
// headerMatcher matches the request against header values.
|
224
|
-
type headerMatcher map[string]string
|
225
|
-
|
226
|
-
func (m headerMatcher) Match(r *http.Request, match *RouteMatch) bool {
|
227
|
-
return matchMapWithString(m, r.Header, true)
|
228
|
-
}
|
229
|
-
|
230
|
-
// Headers adds a matcher for request header values.
|
231
|
-
// It accepts a sequence of key/value pairs to be matched. For example:
|
232
|
-
//
|
233
|
-
// r := mux.NewRouter()
|
234
|
-
// r.Headers("Content-Type", "application/json",
|
235
|
-
// "X-Requested-With", "XMLHttpRequest")
|
236
|
-
//
|
237
|
-
// The above route will only match if both request header values match.
|
238
|
-
// If the value is an empty string, it will match any value if the key is set.
|
239
|
-
func (r *Route) Headers(pairs ...string) *Route {
|
240
|
-
if r.err == nil {
|
241
|
-
var headers map[string]string
|
242
|
-
headers, r.err = mapFromPairsToString(pairs...)
|
243
|
-
return r.addMatcher(headerMatcher(headers))
|
244
|
-
}
|
245
|
-
return r
|
246
|
-
}
|
247
|
-
|
248
|
-
// headerRegexMatcher matches the request against the route given a regex for the header
|
249
|
-
type headerRegexMatcher map[string]*regexp.Regexp
|
250
|
-
|
251
|
-
func (m headerRegexMatcher) Match(r *http.Request, match *RouteMatch) bool {
|
252
|
-
return matchMapWithRegex(m, r.Header, true)
|
253
|
-
}
|
254
|
-
|
255
|
-
// HeadersRegexp accepts a sequence of key/value pairs, where the value has regex
|
256
|
-
// support. For example:
|
257
|
-
//
|
258
|
-
// r := mux.NewRouter()
|
259
|
-
// r.HeadersRegexp("Content-Type", "application/(text|json)",
|
260
|
-
// "X-Requested-With", "XMLHttpRequest")
|
261
|
-
//
|
262
|
-
// The above route will only match if both the request header matches both regular expressions.
|
263
|
-
// If the value is an empty string, it will match any value if the key is set.
|
264
|
-
// Use the start and end of string anchors (^ and $) to match an exact value.
|
265
|
-
func (r *Route) HeadersRegexp(pairs ...string) *Route {
|
266
|
-
if r.err == nil {
|
267
|
-
var headers map[string]*regexp.Regexp
|
268
|
-
headers, r.err = mapFromPairsToRegex(pairs...)
|
269
|
-
return r.addMatcher(headerRegexMatcher(headers))
|
270
|
-
}
|
271
|
-
return r
|
272
|
-
}
|
273
|
-
|
274
|
-
// Host -----------------------------------------------------------------------
|
275
|
-
|
276
|
-
// Host adds a matcher for the URL host.
|
277
|
-
// It accepts a template with zero or more URL variables enclosed by {}.
|
278
|
-
// Variables can define an optional regexp pattern to be matched:
|
279
|
-
//
|
280
|
-
// - {name} matches anything until the next dot.
|
281
|
-
//
|
282
|
-
// - {name:pattern} matches the given regexp pattern.
|
283
|
-
//
|
284
|
-
// For example:
|
285
|
-
//
|
286
|
-
// r := mux.NewRouter()
|
287
|
-
// r.Host("www.example.com")
|
288
|
-
// r.Host("{subdomain}.domain.com")
|
289
|
-
// r.Host("{subdomain:[a-z]+}.domain.com")
|
290
|
-
//
|
291
|
-
// Variable names must be unique in a given route. They can be retrieved
|
292
|
-
// calling mux.Vars(request).
|
293
|
-
func (r *Route) Host(tpl string) *Route {
|
294
|
-
r.err = r.addRegexpMatcher(tpl, regexpTypeHost)
|
295
|
-
return r
|
296
|
-
}
|
297
|
-
|
298
|
-
// MatcherFunc ----------------------------------------------------------------
|
299
|
-
|
300
|
-
// MatcherFunc is the function signature used by custom matchers.
|
301
|
-
type MatcherFunc func(*http.Request, *RouteMatch) bool
|
302
|
-
|
303
|
-
// Match returns the match for a given request.
|
304
|
-
func (m MatcherFunc) Match(r *http.Request, match *RouteMatch) bool {
|
305
|
-
return m(r, match)
|
306
|
-
}
|
307
|
-
|
308
|
-
// MatcherFunc adds a custom function to be used as request matcher.
|
309
|
-
func (r *Route) MatcherFunc(f MatcherFunc) *Route {
|
310
|
-
return r.addMatcher(f)
|
311
|
-
}
|
312
|
-
|
313
|
-
// Methods --------------------------------------------------------------------
|
314
|
-
|
315
|
-
// methodMatcher matches the request against HTTP methods.
|
316
|
-
type methodMatcher []string
|
317
|
-
|
318
|
-
func (m methodMatcher) Match(r *http.Request, match *RouteMatch) bool {
|
319
|
-
return matchInArray(m, r.Method)
|
320
|
-
}
|
321
|
-
|
322
|
-
// Methods adds a matcher for HTTP methods.
|
323
|
-
// It accepts a sequence of one or more methods to be matched, e.g.:
|
324
|
-
// "GET", "POST", "PUT".
|
325
|
-
func (r *Route) Methods(methods ...string) *Route {
|
326
|
-
for k, v := range methods {
|
327
|
-
methods[k] = strings.ToUpper(v)
|
328
|
-
}
|
329
|
-
return r.addMatcher(methodMatcher(methods))
|
330
|
-
}
|
331
|
-
|
332
|
-
// Path -----------------------------------------------------------------------
|
333
|
-
|
334
|
-
// Path adds a matcher for the URL path.
|
335
|
-
// It accepts a template with zero or more URL variables enclosed by {}. The
|
336
|
-
// template must start with a "/".
|
337
|
-
// Variables can define an optional regexp pattern to be matched:
|
338
|
-
//
|
339
|
-
// - {name} matches anything until the next slash.
|
340
|
-
//
|
341
|
-
// - {name:pattern} matches the given regexp pattern.
|
342
|
-
//
|
343
|
-
// For example:
|
344
|
-
//
|
345
|
-
// r := mux.NewRouter()
|
346
|
-
// r.Path("/products/").Handler(ProductsHandler)
|
347
|
-
// r.Path("/products/{key}").Handler(ProductsHandler)
|
348
|
-
// r.Path("/articles/{category}/{id:[0-9]+}").
|
349
|
-
// Handler(ArticleHandler)
|
350
|
-
//
|
351
|
-
// Variable names must be unique in a given route. They can be retrieved
|
352
|
-
// calling mux.Vars(request).
|
353
|
-
func (r *Route) Path(tpl string) *Route {
|
354
|
-
r.err = r.addRegexpMatcher(tpl, regexpTypePath)
|
355
|
-
return r
|
356
|
-
}
|
357
|
-
|
358
|
-
// PathPrefix -----------------------------------------------------------------
|
359
|
-
|
360
|
-
// PathPrefix adds a matcher for the URL path prefix. This matches if the given
|
361
|
-
// template is a prefix of the full URL path. See Route.Path() for details on
|
362
|
-
// the tpl argument.
|
363
|
-
//
|
364
|
-
// Note that it does not treat slashes specially ("/foobar/" will be matched by
|
365
|
-
// the prefix "/foo") so you may want to use a trailing slash here.
|
366
|
-
//
|
367
|
-
// Also note that the setting of Router.StrictSlash() has no effect on routes
|
368
|
-
// with a PathPrefix matcher.
|
369
|
-
func (r *Route) PathPrefix(tpl string) *Route {
|
370
|
-
r.err = r.addRegexpMatcher(tpl, regexpTypePrefix)
|
371
|
-
return r
|
372
|
-
}
|
373
|
-
|
374
|
-
// Query ----------------------------------------------------------------------
|
375
|
-
|
376
|
-
// Queries adds a matcher for URL query values.
|
377
|
-
// It accepts a sequence of key/value pairs. Values may define variables.
|
378
|
-
// For example:
|
379
|
-
//
|
380
|
-
// r := mux.NewRouter()
|
381
|
-
// r.Queries("foo", "bar", "id", "{id:[0-9]+}")
|
382
|
-
//
|
383
|
-
// The above route will only match if the URL contains the defined queries
|
384
|
-
// values, e.g.: ?foo=bar&id=42.
|
385
|
-
//
|
386
|
-
// If the value is an empty string, it will match any value if the key is set.
|
387
|
-
//
|
388
|
-
// Variables can define an optional regexp pattern to be matched:
|
389
|
-
//
|
390
|
-
// - {name} matches anything until the next slash.
|
391
|
-
//
|
392
|
-
// - {name:pattern} matches the given regexp pattern.
|
393
|
-
func (r *Route) Queries(pairs ...string) *Route {
|
394
|
-
length := len(pairs)
|
395
|
-
if length%2 != 0 {
|
396
|
-
r.err = fmt.Errorf(
|
397
|
-
"mux: number of parameters must be multiple of 2, got %v", pairs)
|
398
|
-
return nil
|
399
|
-
}
|
400
|
-
for i := 0; i < length; i += 2 {
|
401
|
-
if r.err = r.addRegexpMatcher(pairs[i]+"="+pairs[i+1], regexpTypeQuery); r.err != nil {
|
402
|
-
return r
|
403
|
-
}
|
404
|
-
}
|
405
|
-
|
406
|
-
return r
|
407
|
-
}
|
408
|
-
|
409
|
-
// Schemes --------------------------------------------------------------------
|
410
|
-
|
411
|
-
// schemeMatcher matches the request against URL schemes.
|
412
|
-
type schemeMatcher []string
|
413
|
-
|
414
|
-
func (m schemeMatcher) Match(r *http.Request, match *RouteMatch) bool {
|
415
|
-
scheme := r.URL.Scheme
|
416
|
-
// https://golang.org/pkg/net/http/#Request
|
417
|
-
// "For [most] server requests, fields other than Path and RawQuery will be
|
418
|
-
// empty."
|
419
|
-
// Since we're an http muxer, the scheme is either going to be http or https
|
420
|
-
// though, so we can just set it based on the tls termination state.
|
421
|
-
if scheme == "" {
|
422
|
-
if r.TLS == nil {
|
423
|
-
scheme = "http"
|
424
|
-
} else {
|
425
|
-
scheme = "https"
|
426
|
-
}
|
427
|
-
}
|
428
|
-
return matchInArray(m, scheme)
|
429
|
-
}
|
430
|
-
|
431
|
-
// Schemes adds a matcher for URL schemes.
|
432
|
-
// It accepts a sequence of schemes to be matched, e.g.: "http", "https".
|
433
|
-
// If the request's URL has a scheme set, it will be matched against.
|
434
|
-
// Generally, the URL scheme will only be set if a previous handler set it,
|
435
|
-
// such as the ProxyHeaders handler from gorilla/handlers.
|
436
|
-
// If unset, the scheme will be determined based on the request's TLS
|
437
|
-
// termination state.
|
438
|
-
// The first argument to Schemes will be used when constructing a route URL.
|
439
|
-
func (r *Route) Schemes(schemes ...string) *Route {
|
440
|
-
for k, v := range schemes {
|
441
|
-
schemes[k] = strings.ToLower(v)
|
442
|
-
}
|
443
|
-
if len(schemes) > 0 {
|
444
|
-
r.buildScheme = schemes[0]
|
445
|
-
}
|
446
|
-
return r.addMatcher(schemeMatcher(schemes))
|
447
|
-
}
|
448
|
-
|
449
|
-
// BuildVarsFunc --------------------------------------------------------------
|
450
|
-
|
451
|
-
// BuildVarsFunc is the function signature used by custom build variable
|
452
|
-
// functions (which can modify route variables before a route's URL is built).
|
453
|
-
type BuildVarsFunc func(map[string]string) map[string]string
|
454
|
-
|
455
|
-
// BuildVarsFunc adds a custom function to be used to modify build variables
|
456
|
-
// before a route's URL is built.
|
457
|
-
func (r *Route) BuildVarsFunc(f BuildVarsFunc) *Route {
|
458
|
-
if r.buildVarsFunc != nil {
|
459
|
-
// compose the old and new functions
|
460
|
-
old := r.buildVarsFunc
|
461
|
-
r.buildVarsFunc = func(m map[string]string) map[string]string {
|
462
|
-
return f(old(m))
|
463
|
-
}
|
464
|
-
} else {
|
465
|
-
r.buildVarsFunc = f
|
466
|
-
}
|
467
|
-
return r
|
468
|
-
}
|
469
|
-
|
470
|
-
// Subrouter ------------------------------------------------------------------
|
471
|
-
|
472
|
-
// Subrouter creates a subrouter for the route.
|
473
|
-
//
|
474
|
-
// It will test the inner routes only if the parent route matched. For example:
|
475
|
-
//
|
476
|
-
// r := mux.NewRouter()
|
477
|
-
// s := r.Host("www.example.com").Subrouter()
|
478
|
-
// s.HandleFunc("/products/", ProductsHandler)
|
479
|
-
// s.HandleFunc("/products/{key}", ProductHandler)
|
480
|
-
// s.HandleFunc("/articles/{category}/{id:[0-9]+}"), ArticleHandler)
|
481
|
-
//
|
482
|
-
// Here, the routes registered in the subrouter won't be tested if the host
|
483
|
-
// doesn't match.
|
484
|
-
func (r *Route) Subrouter() *Router {
|
485
|
-
// initialize a subrouter with a copy of the parent route's configuration
|
486
|
-
router := &Router{routeConf: copyRouteConf(r.routeConf), namedRoutes: r.namedRoutes}
|
487
|
-
r.addMatcher(router)
|
488
|
-
return router
|
489
|
-
}
|
490
|
-
|
491
|
-
// ----------------------------------------------------------------------------
|
492
|
-
// URL building
|
493
|
-
// ----------------------------------------------------------------------------
|
494
|
-
|
495
|
-
// URL builds a URL for the route.
|
496
|
-
//
|
497
|
-
// It accepts a sequence of key/value pairs for the route variables. For
|
498
|
-
// example, given this route:
|
499
|
-
//
|
500
|
-
// r := mux.NewRouter()
|
501
|
-
// r.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler).
|
502
|
-
// Name("article")
|
503
|
-
//
|
504
|
-
// ...a URL for it can be built using:
|
505
|
-
//
|
506
|
-
// url, err := r.Get("article").URL("category", "technology", "id", "42")
|
507
|
-
//
|
508
|
-
// ...which will return an url.URL with the following path:
|
509
|
-
//
|
510
|
-
// "/articles/technology/42"
|
511
|
-
//
|
512
|
-
// This also works for host variables:
|
513
|
-
//
|
514
|
-
// r := mux.NewRouter()
|
515
|
-
// r.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler).
|
516
|
-
// Host("{subdomain}.domain.com").
|
517
|
-
// Name("article")
|
518
|
-
//
|
519
|
-
// // url.String() will be "http://news.domain.com/articles/technology/42"
|
520
|
-
// url, err := r.Get("article").URL("subdomain", "news",
|
521
|
-
// "category", "technology",
|
522
|
-
// "id", "42")
|
523
|
-
//
|
524
|
-
// The scheme of the resulting url will be the first argument that was passed to Schemes:
|
525
|
-
//
|
526
|
-
// // url.String() will be "https://example.com"
|
527
|
-
// r := mux.NewRouter()
|
528
|
-
// url, err := r.Host("example.com")
|
529
|
-
// .Schemes("https", "http").URL()
|
530
|
-
//
|
531
|
-
// All variables defined in the route are required, and their values must
|
532
|
-
// conform to the corresponding patterns.
|
533
|
-
func (r *Route) URL(pairs ...string) (*url.URL, error) {
|
534
|
-
if r.err != nil {
|
535
|
-
return nil, r.err
|
536
|
-
}
|
537
|
-
values, err := r.prepareVars(pairs...)
|
538
|
-
if err != nil {
|
539
|
-
return nil, err
|
540
|
-
}
|
541
|
-
var scheme, host, path string
|
542
|
-
queries := make([]string, 0, len(r.regexp.queries))
|
543
|
-
if r.regexp.host != nil {
|
544
|
-
if host, err = r.regexp.host.url(values); err != nil {
|
545
|
-
return nil, err
|
546
|
-
}
|
547
|
-
scheme = "http"
|
548
|
-
if r.buildScheme != "" {
|
549
|
-
scheme = r.buildScheme
|
550
|
-
}
|
551
|
-
}
|
552
|
-
if r.regexp.path != nil {
|
553
|
-
if path, err = r.regexp.path.url(values); err != nil {
|
554
|
-
return nil, err
|
555
|
-
}
|
556
|
-
}
|
557
|
-
for _, q := range r.regexp.queries {
|
558
|
-
var query string
|
559
|
-
if query, err = q.url(values); err != nil {
|
560
|
-
return nil, err
|
561
|
-
}
|
562
|
-
queries = append(queries, query)
|
563
|
-
}
|
564
|
-
return &url.URL{
|
565
|
-
Scheme: scheme,
|
566
|
-
Host: host,
|
567
|
-
Path: path,
|
568
|
-
RawQuery: strings.Join(queries, "&"),
|
569
|
-
}, nil
|
570
|
-
}
|
571
|
-
|
572
|
-
// URLHost builds the host part of the URL for a route. See Route.URL().
|
573
|
-
//
|
574
|
-
// The route must have a host defined.
|
575
|
-
func (r *Route) URLHost(pairs ...string) (*url.URL, error) {
|
576
|
-
if r.err != nil {
|
577
|
-
return nil, r.err
|
578
|
-
}
|
579
|
-
if r.regexp.host == nil {
|
580
|
-
return nil, errors.New("mux: route doesn't have a host")
|
581
|
-
}
|
582
|
-
values, err := r.prepareVars(pairs...)
|
583
|
-
if err != nil {
|
584
|
-
return nil, err
|
585
|
-
}
|
586
|
-
host, err := r.regexp.host.url(values)
|
587
|
-
if err != nil {
|
588
|
-
return nil, err
|
589
|
-
}
|
590
|
-
u := &url.URL{
|
591
|
-
Scheme: "http",
|
592
|
-
Host: host,
|
593
|
-
}
|
594
|
-
if r.buildScheme != "" {
|
595
|
-
u.Scheme = r.buildScheme
|
596
|
-
}
|
597
|
-
return u, nil
|
598
|
-
}
|
599
|
-
|
600
|
-
// URLPath builds the path part of the URL for a route. See Route.URL().
|
601
|
-
//
|
602
|
-
// The route must have a path defined.
|
603
|
-
func (r *Route) URLPath(pairs ...string) (*url.URL, error) {
|
604
|
-
if r.err != nil {
|
605
|
-
return nil, r.err
|
606
|
-
}
|
607
|
-
if r.regexp.path == nil {
|
608
|
-
return nil, errors.New("mux: route doesn't have a path")
|
609
|
-
}
|
610
|
-
values, err := r.prepareVars(pairs...)
|
611
|
-
if err != nil {
|
612
|
-
return nil, err
|
613
|
-
}
|
614
|
-
path, err := r.regexp.path.url(values)
|
615
|
-
if err != nil {
|
616
|
-
return nil, err
|
617
|
-
}
|
618
|
-
return &url.URL{
|
619
|
-
Path: path,
|
620
|
-
}, nil
|
621
|
-
}
|
622
|
-
|
623
|
-
// GetPathTemplate returns the template used to build the
|
624
|
-
// route match.
|
625
|
-
// This is useful for building simple REST API documentation and for instrumentation
|
626
|
-
// against third-party services.
|
627
|
-
// An error will be returned if the route does not define a path.
|
628
|
-
func (r *Route) GetPathTemplate() (string, error) {
|
629
|
-
if r.err != nil {
|
630
|
-
return "", r.err
|
631
|
-
}
|
632
|
-
if r.regexp.path == nil {
|
633
|
-
return "", errors.New("mux: route doesn't have a path")
|
634
|
-
}
|
635
|
-
return r.regexp.path.template, nil
|
636
|
-
}
|
637
|
-
|
638
|
-
// GetPathRegexp returns the expanded regular expression used to match route path.
|
639
|
-
// This is useful for building simple REST API documentation and for instrumentation
|
640
|
-
// against third-party services.
|
641
|
-
// An error will be returned if the route does not define a path.
|
642
|
-
func (r *Route) GetPathRegexp() (string, error) {
|
643
|
-
if r.err != nil {
|
644
|
-
return "", r.err
|
645
|
-
}
|
646
|
-
if r.regexp.path == nil {
|
647
|
-
return "", errors.New("mux: route does not have a path")
|
648
|
-
}
|
649
|
-
return r.regexp.path.regexp.String(), nil
|
650
|
-
}
|
651
|
-
|
652
|
-
// GetQueriesRegexp returns the expanded regular expressions used to match the
|
653
|
-
// route queries.
|
654
|
-
// This is useful for building simple REST API documentation and for instrumentation
|
655
|
-
// against third-party services.
|
656
|
-
// An error will be returned if the route does not have queries.
|
657
|
-
func (r *Route) GetQueriesRegexp() ([]string, error) {
|
658
|
-
if r.err != nil {
|
659
|
-
return nil, r.err
|
660
|
-
}
|
661
|
-
if r.regexp.queries == nil {
|
662
|
-
return nil, errors.New("mux: route doesn't have queries")
|
663
|
-
}
|
664
|
-
queries := make([]string, 0, len(r.regexp.queries))
|
665
|
-
for _, query := range r.regexp.queries {
|
666
|
-
queries = append(queries, query.regexp.String())
|
667
|
-
}
|
668
|
-
return queries, nil
|
669
|
-
}
|
670
|
-
|
671
|
-
// GetQueriesTemplates returns the templates used to build the
|
672
|
-
// query matching.
|
673
|
-
// This is useful for building simple REST API documentation and for instrumentation
|
674
|
-
// against third-party services.
|
675
|
-
// An error will be returned if the route does not define queries.
|
676
|
-
func (r *Route) GetQueriesTemplates() ([]string, error) {
|
677
|
-
if r.err != nil {
|
678
|
-
return nil, r.err
|
679
|
-
}
|
680
|
-
if r.regexp.queries == nil {
|
681
|
-
return nil, errors.New("mux: route doesn't have queries")
|
682
|
-
}
|
683
|
-
queries := make([]string, 0, len(r.regexp.queries))
|
684
|
-
for _, query := range r.regexp.queries {
|
685
|
-
queries = append(queries, query.template)
|
686
|
-
}
|
687
|
-
return queries, nil
|
688
|
-
}
|
689
|
-
|
690
|
-
// GetMethods returns the methods the route matches against
|
691
|
-
// This is useful for building simple REST API documentation and for instrumentation
|
692
|
-
// against third-party services.
|
693
|
-
// An error will be returned if route does not have methods.
|
694
|
-
func (r *Route) GetMethods() ([]string, error) {
|
695
|
-
if r.err != nil {
|
696
|
-
return nil, r.err
|
697
|
-
}
|
698
|
-
for _, m := range r.matchers {
|
699
|
-
if methods, ok := m.(methodMatcher); ok {
|
700
|
-
return []string(methods), nil
|
701
|
-
}
|
702
|
-
}
|
703
|
-
return nil, errors.New("mux: route doesn't have methods")
|
704
|
-
}
|
705
|
-
|
706
|
-
// GetHostTemplate returns the template used to build the
|
707
|
-
// route match.
|
708
|
-
// This is useful for building simple REST API documentation and for instrumentation
|
709
|
-
// against third-party services.
|
710
|
-
// An error will be returned if the route does not define a host.
|
711
|
-
func (r *Route) GetHostTemplate() (string, error) {
|
712
|
-
if r.err != nil {
|
713
|
-
return "", r.err
|
714
|
-
}
|
715
|
-
if r.regexp.host == nil {
|
716
|
-
return "", errors.New("mux: route doesn't have a host")
|
717
|
-
}
|
718
|
-
return r.regexp.host.template, nil
|
719
|
-
}
|
720
|
-
|
721
|
-
// prepareVars converts the route variable pairs into a map. If the route has a
|
722
|
-
// BuildVarsFunc, it is invoked.
|
723
|
-
func (r *Route) prepareVars(pairs ...string) (map[string]string, error) {
|
724
|
-
m, err := mapFromPairsToString(pairs...)
|
725
|
-
if err != nil {
|
726
|
-
return nil, err
|
727
|
-
}
|
728
|
-
return r.buildVars(m), nil
|
729
|
-
}
|
730
|
-
|
731
|
-
func (r *Route) buildVars(m map[string]string) map[string]string {
|
732
|
-
if r.buildVarsFunc != nil {
|
733
|
-
m = r.buildVarsFunc(m)
|
734
|
-
}
|
735
|
-
return m
|
736
|
-
}
|