1
+ {-# LANGUAGE DataKinds #-}
2
+ {-# LANGUAGE OverloadedStrings #-}
3
+ {-# LANGUAGE RecordWildCards #-}
1
4
{-# OPTIONS_GHC -fno-warn-orphans #-}
2
- {-# LANGUAGE
3
- DataKinds,
4
- FlexibleInstances,
5
- MultiParamTypeClasses,
6
- OverloadedStrings,
7
- RecordWildCards,
8
- TypeOperators
9
- #-}
10
5
11
6
module Network.WebDav.HTTPExtensions where
12
7
13
- {-
14
- import Control.Monad.IO.Class
15
- import Data.ByteString (ByteString)
16
- import qualified Data.ByteString as ByteString
17
- import qualified Data.ByteString.Char8 as Char8
18
- import qualified Data.ByteString.Lazy.Char8 as Lazy.Char8
19
-
20
- import Data.List
21
- import Data.Traversable
22
-
23
- import Network.HTTP.Types.URI
24
- -}
25
8
import Servant
26
9
import Servant.Foreign.Internal
27
- {-
28
- import System.Directory
29
-
30
- import Network.Wai.Handler.Warp
31
- import Network.Wai.Middleware.AddHeaders
32
- import Network.Wai.Middleware.RequestLogger
33
- import Network.Wai.Middleware.Servant.Options
34
- -}
35
10
import Text.XML.Light
36
- {-
37
- import Network.WebDav.Constants
38
- import Network.WebDav.Properties
39
- -}
40
11
41
- data DavMethod = MKCOL | PROPFIND | PROPPATCH | LOCK | UNLOCK | ORDERPATCH | COPY | MOVE
12
+
13
+ data DavMethod
14
+ = MKCOL
15
+ | PROPFIND
16
+ | PROPPATCH
17
+ | LOCK
18
+ | UNLOCK
19
+ | ORDERPATCH
20
+ | COPY
21
+ | MOVE
42
22
43
23
44
24
-- OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, COPY, MOVE
25
+ -- are already defined by Servant
45
26
46
27
instance ReflectMethod 'MKCOL where
47
28
reflectMethod _ = " MKCOL"
@@ -55,38 +36,41 @@ instance ReflectMethod 'UNLOCK where
55
36
reflectMethod _ = " UNLOCK"
56
37
instance ReflectMethod 'ORDERPATCH where
57
38
reflectMethod _ = " ORDERPATCH"
58
- -- instance ReflectMethod 'HEAD where
39
+
40
+
41
+ -- instance ReflectMethod 'HEAD where
59
42
-- reflectMethod _ = "HEAD"
60
- -- instance ReflectMethod 'TRACE where
43
+ -- instance ReflectMethod 'TRACE where
61
44
-- reflectMethod _ = "TRACE"
62
45
instance ReflectMethod 'COPY where
63
46
reflectMethod _ = " COPY"
64
47
instance ReflectMethod 'MOVE where
65
48
reflectMethod _ = " MOVE"
66
49
67
50
68
-
69
51
type Mkcol = Verb 'MKCOL 200
70
52
type Propfind = Verb 'PROPFIND 207
71
53
type Proppatch = Verb 'PROPPATCH 200
72
54
type Lock = Verb 'LOCK 200
73
55
type Unlock = Verb 'UNLOCK 200
74
56
type Orderpatch = Verb 'ORDERPATCH 200
75
- -- type Head = Verb 'HEAD 200
76
- -- type Trace = Verb 'TRACE 200
57
+
58
+
59
+ -- type Head = Verb 'HEAD 200
60
+ -- type Trace = Verb 'TRACE 200
77
61
type Copy = Verb 'COPY 200
78
62
type Move = Verb 'MOVE 200
79
63
64
+
80
65
data XML = XML
81
66
67
+
82
68
instance MimeUnrender XML Element where
83
69
mimeUnrender _ x =
84
70
case parseXMLDoc x of
85
- Nothing -> Left $ " Bad XML Input: " ++ show x
86
- Just doc -> Right doc
71
+ Nothing -> Left $ " Bad XML Input: " ++ show x
72
+ Just doc -> Right doc
87
73
88
74
89
75
instance Accept XML where
90
76
contentType _ = " application/xml"
91
- instance NotFound where
92
-
0 commit comments