diff --git a/src/Servant/Multipart.hs b/src/Servant/Multipart.hs index 68aae04..6423193 100644 --- a/src/Servant/Multipart.hs +++ b/src/Servant/Multipart.hs @@ -173,6 +173,12 @@ data MultipartData tag = MultipartData , files :: [FileData tag] } +instance Semigroup (MultipartData tag) where + d1 <> d2 = MultipartData (inputs d1 <> inputs d2) (files d1 <> files d2) + +instance Monoid (MultipartData tag) where + mempty = MultipartData [] [] + fromRaw :: forall tag. ([Network.Wai.Parse.Param], [File (MultipartResult tag)]) -> MultipartData tag fromRaw (inputs, files) = MultipartData is fs @@ -274,6 +280,9 @@ class ToMultipart tag a where instance ToMultipart tag (MultipartData tag) where toMultipart = id +instance (ToMultipart tag a, Foldable t) => ToMultipart tag (t a) where + toMultipart xs = foldMap toMultipart xs + -- | Upon seeing @MultipartForm a :> ...@ in an API type, --- servant-server will hand a value of type @a@ to your handler -- assuming the request body's content type is