@@ -51,6 +51,8 @@ data QueryArg = QueryArg
51 , _argType :: ArgType
51 , _argType :: ArgType
52 } deriving (Eq, Show)
52 } deriving (Eq, Show)
54+type HeaderArg = String
54data Url = Url
56data Url = Url
55 { _path :: Path
57 { _path :: Path
56 , _queryStr :: [QueryArg]
58 , _queryStr :: [QueryArg]
@@ -63,10 +65,11 @@ type FunctionName = String
63type Method = String
65type Method = String
65data AjaxReq = AjaxReq
67data AjaxReq = AjaxReq
66− { _reqUrl :: Url
68+ { _reqUrl :: Url
67− , _reqMethod :: Method
69+ , _reqMethod :: Method
70+ , _reqHeaders :: [HeaderArg]
68− , _reqBody :: Bool
71+ , _reqBody :: Bool
69− , _funcName :: FunctionName
72+ , _funcName :: FunctionName
70 } deriving (Eq, Show)
73 } deriving (Eq, Show)
72makeLenses ''QueryArg
75makeLenses ''QueryArg
@@ -96,7 +99,7 @@ paramToStr qarg notTheEnd =
96 where name = qarg ^. argName
99 where name = qarg ^. argName
98defReq :: AjaxReq
101defReq :: AjaxReq
99−defReq = AjaxReq defUrl "GET" False ""
102+defReq = AjaxReq defUrl "GET" [] False ""
101class HasJQ layout where
104class HasJQ layout where
102 type JQ layout :: *
105 type JQ layout :: *
@@ -134,6 +137,16 @@ instance HasJQ (Get a) where
134 req & funcName %~ ("get" <>)
137 req & funcName %~ ("get" <>)
135 & reqMethod .~ "GET"
138 & reqMethod .~ "GET"
140+instance (KnownSymbol sym, HasJQ sublayout)
141+ => HasJQ (Header sym a :> sublayout) where
142+ type JQ (Header sym a :> sublayout) = JQ sublayout
144+ jqueryFor Proxy req =
145+ jqueryFor subP (req & reqHeaders <>~ [hname])
147+ where hname = symbolVal (Proxy :: Proxy sym)
148+ subP = Proxy :: Proxy sublayout
137instance HasJQ (Post a) where
150instance HasJQ (Post a) where
138 type JQ (Post a) = AjaxReq
151 type JQ (Post a) = AjaxReq