From 2eda7e7021019e406a8ea72528b021a1be73e71e Mon Sep 17 00:00:00 2001 From: Antoine Mercadal Date: Tue, 16 Apr 2019 17:32:00 -0700 Subject: [PATCH] new/maniphttp: added ExtractEncoding helper --- maniphttp/helpers.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/maniphttp/helpers.go b/maniphttp/helpers.go index 397ead58..e019a7d5 100644 --- a/maniphttp/helpers.go +++ b/maniphttp/helpers.go @@ -4,6 +4,7 @@ import ( "crypto/tls" "net/http" + "go.aporeto.io/elemental" "go.aporeto.io/manipulate" ) @@ -63,6 +64,17 @@ func ExtractTLSConfig(manipulator manipulate.Manipulator) *tls.Config { } } +// ExtractEncoding returns the encoding used by the given manipulator. +func ExtractEncoding(manipulator manipulate.Manipulator) elemental.EncodingType { + + m, ok := manipulator.(*httpManipulator) + if !ok { + panic("You can only pass a HTTP Manipulator to ExtractEncoding") + } + + return m.encoding +} + // SetGlobalHeaders sets the given headers to all requests that will be sent. func SetGlobalHeaders(manipulator manipulate.Manipulator, headers http.Header) {