diff --git a/task/http_request.go b/task/http_request.go index aac4eeb..bffffb8 100644 --- a/task/http_request.go +++ b/task/http_request.go @@ -2,6 +2,7 @@ package task import ( "encoding/json" + "encoding/xml" "fmt" "io" "net/http" @@ -51,6 +52,12 @@ func (z *HttpRequest[T]) Json() func(r *HttpRequest[T]) *HttpRequest[T] { }) } +func (z *HttpRequest[T]) Xml() func(r *HttpRequest[T]) *HttpRequest[T] { + return z.With(func(r io.Reader) Decoder { + return xml.NewDecoder(r) + }) +} + func (_ *HttpRequest[T]) NoErr() func(r *HttpRequest[T]) bool { return func(r *HttpRequest[T]) bool { return r.err == nil