From 61f1b4461e8db274c02bd41591efe8b012a9eaaf Mon Sep 17 00:00:00 2001 From: a Date: Sat, 26 Mar 2022 21:45:23 -0500 Subject: [PATCH] lol xml --- task/http_request.go | 7 +++++++ 1 file changed, 7 insertions(+) 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