1
0
Fork 0
mirror of https://github.com/Luzifer/share.git synced 2024-12-21 11:01:17 +00:00
share/vendor/github.com/aws/aws-sdk-go/service/route53/customizations.go

43 lines
1.1 KiB
Go
Raw Normal View History

2017-12-02 14:25:54 +00:00
package route53
import (
"net/url"
"regexp"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/client"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/private/protocol/restxml"
)
func init() {
initClient = func(c *client.Client) {
c.Handlers.Build.PushBack(sanitizeURL)
}
initRequest = func(r *request.Request) {
switch r.Operation.Name {
case opChangeResourceRecordSets:
r.Handlers.UnmarshalError.Remove(restxml.UnmarshalErrorHandler)
r.Handlers.UnmarshalError.PushBack(unmarshalChangeResourceRecordSetsError)
}
}
}
var reSanitizeURL = regexp.MustCompile(`\/%2F\w+%2F`)
func sanitizeURL(r *request.Request) {
r.HTTPRequest.URL.RawPath =
reSanitizeURL.ReplaceAllString(r.HTTPRequest.URL.RawPath, "/")
// Update Path so that it reflects the cleaned RawPath
updated, err := url.Parse(r.HTTPRequest.URL.RawPath)
if err != nil {
r.Error = awserr.New("SerializationError", "failed to clean Route53 URL", err)
return
}
// Take the updated path so the requests's URL Path has parity with RawPath.
r.HTTPRequest.URL.Path = updated.Path
}