1
1
# Module Documentation
2
2
3
+ ## Module Type.Proxy
4
+
5
+ #### ` Proxy `
6
+
7
+ ``` purescript
8
+ data Proxy a
9
+ = Proxy
10
+ ```
11
+
12
+
13
+
3
14
## Module Network.HTTP.Affjax
4
15
5
16
#### ` Ajax `
@@ -18,13 +29,19 @@ type Affjax e a = Aff (ajax :: Ajax | e) (AffjaxResponse a)
18
29
19
30
The type for Affjax requests.
20
31
21
- #### ` AffjaxOptions `
32
+ #### ` AffjaxRequest `
22
33
23
34
``` purescript
24
- data AffjaxOptions :: *
35
+ type AffjaxRequest a = { password :: Maybe String, username :: Maybe String, content :: Maybe a, headers :: [RequestHeader], url :: URL, method :: Method }
36
+ ```
37
+
38
+
39
+ #### ` defaultRequest `
40
+
41
+ ``` purescript
42
+ defaultRequest :: AffjaxRequest Unit
25
43
```
26
44
27
- Options type for Affjax requests.
28
45
29
46
#### ` AffjaxResponse `
30
47
@@ -42,109 +59,53 @@ type URL = String
42
59
43
60
Type alias for URL strings to aid readability of types.
44
61
45
- #### ` url `
46
-
47
- ``` purescript
48
- url :: Option AffjaxOptions URL
49
- ```
50
-
51
- Sets the URL for a request.
52
-
53
- #### ` method `
54
-
55
- ``` purescript
56
- method :: Option AffjaxOptions Method
57
- ```
58
-
59
- Sets the HTTP method for a request.
60
-
61
- #### ` content `
62
-
63
- ``` purescript
64
- content :: Option AffjaxOptions RequestContent
65
- ```
66
-
67
- Sets the content to send in a request.
68
-
69
- #### ` headers `
70
-
71
- ``` purescript
72
- headers :: Option AffjaxOptions [RequestHeader]
73
- ```
74
-
75
- Sets the headers to send with a request.
76
-
77
- #### ` username `
78
-
79
- ``` purescript
80
- username :: Option AffjaxOptions String
81
- ```
82
-
83
- Sets the HTTP auth username to send with a request.
84
-
85
- #### ` password `
86
-
87
- ``` purescript
88
- password :: Option AffjaxOptions String
89
- ```
90
-
91
- Sets the HTTP auth password to send with a request.
92
-
93
62
#### ` affjax `
94
63
95
64
``` purescript
96
- affjax :: forall e a. Responsable a -> Options AffjaxOptions -> Affjax e a
97
- ```
98
-
99
- Runs a request.
100
-
101
- #### ` affjax' `
102
-
103
- ``` purescript
104
- affjax' :: forall e a. Responsable a -> Options AffjaxOptions -> (Error -> Eff (ajax :: Ajax | e) Unit) -> (AffjaxResponse a -> Eff (ajax :: Ajax | e) Unit) -> Eff (ajax :: Ajax | e) Unit
65
+ affjax :: forall e a b. (Requestable a, Responsable b) => AffjaxRequest a -> Affjax e b
105
66
```
106
67
107
- Runs a request directly in Eff .
68
+ Makes an ` Affjax ` request .
108
69
109
70
#### ` get `
110
71
111
72
``` purescript
112
- get :: forall e a. URL -> Responsable a -> Affjax e a
73
+ get :: forall e a. ( Responsable a) => URL -> Affjax e a
113
74
```
114
75
115
76
116
77
#### ` post `
117
78
118
79
``` purescript
119
- post :: forall e a. URL -> Responsable a -> RequestContent -> Affjax e a
80
+ post :: forall e a b. (Requestable a, Responsable b) => URL -> a -> Affjax e b
120
81
```
121
82
122
83
123
84
#### ` post_ `
124
85
125
86
``` purescript
126
- post_ :: forall e. URL -> RequestContent -> Affjax e Unit
87
+ post_ :: forall e a. (Requestable a) => URL -> a -> Affjax e Unit
127
88
```
128
89
129
90
130
91
#### ` put `
131
92
132
93
``` purescript
133
- put :: forall e a. URL -> Responsable a -> RequestContent -> Affjax e a
94
+ put :: forall e a b. (Requestable a, Responsable b) => URL -> a -> Affjax e b
134
95
```
135
96
136
97
137
98
#### ` put_ `
138
99
139
100
``` purescript
140
- put_ :: forall e. URL -> RequestContent -> Affjax e Unit
101
+ put_ :: forall e a. (Requestable a) => URL -> a -> Affjax e Unit
141
102
```
142
103
143
104
144
105
#### ` delete `
145
106
146
107
``` purescript
147
- delete :: forall e a. URL -> Responsable a -> Affjax e a
108
+ delete :: forall e a. ( Responsable a) => URL -> Affjax e a
148
109
```
149
110
150
111
@@ -155,6 +116,14 @@ delete_ :: forall e. URL -> Affjax e Unit
155
116
```
156
117
157
118
119
+ #### ` affjax' `
120
+
121
+ ``` purescript
122
+ affjax' :: forall e a b. (Requestable a, Responsable b) => AffjaxRequest a -> (Error -> Eff (ajax :: Ajax | e) Unit) -> (AffjaxResponse b -> Eff (ajax :: Ajax | e) Unit) -> Eff (ajax :: Ajax | e) Unit
123
+ ```
124
+
125
+ Run a request directly without using ` Aff ` .
126
+
158
127
159
128
## Module Network.HTTP.Method
160
129
@@ -189,13 +158,6 @@ instance showMethod :: Show Method
189
158
```
190
159
191
160
192
- #### ` isOptionMethod `
193
-
194
- ``` purescript
195
- instance isOptionMethod :: IsOption Method
196
- ```
197
-
198
-
199
161
#### ` methodToString `
200
162
201
163
``` purescript
@@ -262,13 +224,6 @@ instance showRequestHeader :: Show RequestHeader
262
224
```
263
225
264
226
265
- #### ` isOptionRequestHeader `
266
-
267
- ``` purescript
268
- instance isOptionRequestHeader :: IsOption RequestHeader
269
- ```
270
-
271
-
272
227
#### ` requestHeaderName `
273
228
274
229
``` purescript
@@ -351,18 +306,11 @@ data RequestContent :: *
351
306
Type representing all content types that be sent via XHR (ArrayBufferView,
352
307
Blob, Document, String, FormData).
353
308
354
- #### ` isOptionRequestContent `
355
-
356
- ``` purescript
357
- instance isOptionRequestContent :: IsOption RequestContent
358
- ```
359
-
360
-
361
309
#### ` Requestable `
362
310
363
311
``` purescript
364
312
class Requestable a where
365
- toContent :: a -> RequestContent
313
+ toRequest :: a -> RequestContent
366
314
```
367
315
368
316
A class for types that can be converted to values that can be sent with
@@ -488,106 +436,43 @@ Type representing content types that be received from an XHR request
488
436
#### ` Responsable `
489
437
490
438
``` purescript
491
- data Responsable a
492
- = Responsable (ResponseContent -> F a) ResponseType
493
- ```
494
-
495
-
496
- #### ` rInt8Array `
497
-
498
- ``` purescript
499
- rInt8Array :: Responsable A.Int8Array
500
- ```
501
-
502
-
503
- #### ` rInt16Array `
504
-
505
- ``` purescript
506
- rInt16Array :: Responsable A.Int16Array
507
- ```
508
-
509
-
510
- #### ` rInt32Array `
511
-
512
- ``` purescript
513
- rInt32Array :: Responsable A.Int32Array
514
- ```
515
-
516
-
517
- #### ` rUint8Array `
518
-
519
- ``` purescript
520
- rUint8Array :: Responsable A.Uint8Array
521
- ```
522
-
523
-
524
- #### ` rUint16Array `
525
-
526
- ``` purescript
527
- rUint16Array :: Responsable A.Uint16Array
528
- ```
529
-
530
-
531
- #### ` rUint32Array `
532
-
533
- ``` purescript
534
- rUint32Array :: Responsable A.Uint32Array
535
- ```
536
-
537
-
538
- #### ` rUint8ClampedArray `
539
-
540
- ``` purescript
541
- rUint8ClampedArray :: Responsable A.Uint8ClampedArray
542
- ```
543
-
544
-
545
- #### ` rFloat32Array `
546
-
547
- ``` purescript
548
- rFloat32Array :: Responsable A.Float32Array
439
+ class Responsable a where
440
+ responseType :: Proxy a -> ResponseType
441
+ fromResponse :: ResponseContent -> F a
549
442
```
550
443
551
444
552
- #### ` rFloat64Array `
445
+ #### ` responsableBlob `
553
446
554
447
``` purescript
555
- rFloat64Array :: Responsable A.Float64Array
448
+ instance responsableBlob :: Responsable Blob
556
449
```
557
450
558
-
559
- #### ` rBlob `
451
+ #### ` responsableDocument `
560
452
561
453
``` purescript
562
- rBlob :: Responsable Blob
454
+ instance responsableDocument :: Responsable Document
563
455
```
564
456
565
457
566
- #### ` rDocument `
458
+ #### ` responsableJSON `
567
459
568
460
``` purescript
569
- rDocument :: Responsable Document
461
+ instance responsableJSON :: Responsable Foreign
570
462
```
571
463
572
464
573
- #### ` rJSON `
465
+ #### ` responsableString `
574
466
575
467
``` purescript
576
- rJSON :: Responsable Foreign
468
+ instance responsableString :: Responsable String
577
469
```
578
470
579
471
580
- #### ` rString `
472
+ #### ` responsableUnit `
581
473
582
474
``` purescript
583
- rString :: Responsable String
584
- ```
585
-
586
-
587
- #### ` rUnit `
588
-
589
- ``` purescript
590
- rUnit :: Responsable Unit
475
+ instance responsableUnit :: Responsable Unit
591
476
```
592
477
593
478
@@ -622,13 +507,6 @@ instance showResponseType :: Show ResponseType
622
507
```
623
508
624
509
625
- #### ` isOptionResponseType `
626
-
627
- ``` purescript
628
- instance isOptionResponseType :: IsOption ResponseType
629
- ```
630
-
631
-
632
510
#### ` ajaxResponseTypeToString `
633
511
634
512
``` purescript
0 commit comments