Skip to content

Commit c8e8053

Browse files
committed
Add more POST and PUT variations
1 parent 7ac8f64 commit c8e8053

File tree

2 files changed

+72
-2
lines changed

2 files changed

+72
-2
lines changed

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,48 +73,91 @@ Makes an `Affjax` request.
7373
get :: forall e a. (Responsable a) => URL -> Affjax e a
7474
```
7575

76+
Makes a `GET` request to the specified URL.
7677

7778
#### `post`
7879

7980
``` purescript
8081
post :: forall e a b. (Requestable a, Responsable b) => URL -> a -> Affjax e b
8182
```
8283

84+
Makes a `POST` request to the specified URL, sending data.
85+
86+
#### `post'`
87+
88+
``` purescript
89+
post' :: forall e a b. (Requestable a, Responsable b) => URL -> Maybe a -> Affjax e b
90+
```
91+
92+
Makes a `POST` request to the specified URL with the option to send data.
8393

8494
#### `post_`
8595

8696
``` purescript
8797
post_ :: forall e a. (Requestable a) => URL -> a -> Affjax e Unit
8898
```
8999

100+
Makes a `POST` request to the specified URL, sending data and ignoring the
101+
response.
102+
103+
#### `post_'`
104+
105+
``` purescript
106+
post_' :: forall e a. (Requestable a) => URL -> Maybe a -> Affjax e Unit
107+
```
108+
109+
Makes a `POST` request to the specified URL with the option to send data,
110+
and ignores the response.
90111

91112
#### `put`
92113

93114
``` purescript
94115
put :: forall e a b. (Requestable a, Responsable b) => URL -> a -> Affjax e b
95116
```
96117

118+
Makes a `PUT` request to the specified URL, sending data.
119+
120+
#### `put'`
121+
122+
``` purescript
123+
put' :: forall e a b. (Requestable a, Responsable b) => URL -> Maybe a -> Affjax e b
124+
```
125+
126+
Makes a `PUT` request to the specified URL with the option to send data.
97127

98128
#### `put_`
99129

100130
``` purescript
101131
put_ :: forall e a. (Requestable a) => URL -> a -> Affjax e Unit
102132
```
103133

134+
Makes a `PUT` request to the specified URL, sending data and ignoring the
135+
response.
136+
137+
#### `put_'`
138+
139+
``` purescript
140+
put_' :: forall e a. (Requestable a) => URL -> Maybe a -> Affjax e Unit
141+
```
142+
143+
Makes a `PUT` request to the specified URL with the option to send data,
144+
and ignores the response.
104145

105146
#### `delete`
106147

107148
``` purescript
108149
delete :: forall e a. (Responsable a) => URL -> Affjax e a
109150
```
110151

152+
Makes a `DELETE` request to the specified URL.
111153

112154
#### `delete_`
113155

114156
``` purescript
115157
delete_ :: forall e. URL -> Affjax e Unit
116158
```
117159

160+
Makes a `DELETE` request to the specified URL and ignores the response.
118161

119162
#### `affjax'`
120163

src/Network/HTTP/Affjax.purs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ module Network.HTTP.Affjax
77
, affjax
88
, affjax'
99
, get
10-
, post, post_
11-
, put, put_
10+
, post, post_, post', post_'
11+
, put, put_, put', put_'
1212
, delete, delete_
1313
) where
1414

@@ -68,24 +68,51 @@ type URL = String
6868
affjax :: forall e a b. (Requestable a, Responsable b) => AffjaxRequest a -> Affjax e b
6969
affjax = makeAff <<< affjax'
7070

71+
-- | Makes a `GET` request to the specified URL.
7172
get :: forall e a. (Responsable a) => URL -> Affjax e a
7273
get u = affjax $ defaultRequest { url = u }
7374

75+
-- | Makes a `POST` request to the specified URL, sending data.
7476
post :: forall e a b. (Requestable a, Responsable b) => URL -> a -> Affjax e b
7577
post u c = affjax $ defaultRequest { method = POST, url = u, content = Just c }
7678

79+
-- | Makes a `POST` request to the specified URL with the option to send data.
80+
post' :: forall e a b. (Requestable a, Responsable b) => URL -> Maybe a -> Affjax e b
81+
post' u c = affjax $ defaultRequest { method = POST, url = u, content = c }
82+
83+
-- | Makes a `POST` request to the specified URL, sending data and ignoring the
84+
-- | response.
7785
post_ :: forall e a. (Requestable a) => URL -> a -> Affjax e Unit
7886
post_ = post
7987

88+
-- | Makes a `POST` request to the specified URL with the option to send data,
89+
-- | and ignores the response.
90+
post_' :: forall e a. (Requestable a) => URL -> Maybe a -> Affjax e Unit
91+
post_' = post'
92+
93+
-- | Makes a `PUT` request to the specified URL, sending data.
8094
put :: forall e a b. (Requestable a, Responsable b) => URL -> a -> Affjax e b
8195
put u c = affjax $ defaultRequest { method = PUT, url = u, content = Just c }
8296

97+
-- | Makes a `PUT` request to the specified URL with the option to send data.
98+
put' :: forall e a b. (Requestable a, Responsable b) => URL -> Maybe a -> Affjax e b
99+
put' u c = affjax $ defaultRequest { method = PUT, url = u, content = c }
100+
101+
-- | Makes a `PUT` request to the specified URL, sending data and ignoring the
102+
-- | response.
83103
put_ :: forall e a. (Requestable a) => URL -> a -> Affjax e Unit
84104
put_ = put
85105

106+
-- | Makes a `PUT` request to the specified URL with the option to send data,
107+
-- | and ignores the response.
108+
put_' :: forall e a. (Requestable a) => URL -> Maybe a -> Affjax e Unit
109+
put_' = put'
110+
111+
-- | Makes a `DELETE` request to the specified URL.
86112
delete :: forall e a. (Responsable a) => URL -> Affjax e a
87113
delete u = affjax $ defaultRequest { method = DELETE, url = u }
88114

115+
-- | Makes a `DELETE` request to the specified URL and ignores the response.
89116
delete_ :: forall e. URL -> Affjax e Unit
90117
delete_ = delete
91118

0 commit comments

Comments
 (0)