1
- # Function HTTP server
1
+ # Functional HTTP server
2
+
3
+ Common Functional Programming Algebraic data types for JavaScript that is compatible with most modern browsers and Deno.
4
+
5
+ [ ![ deno land
] ( http://img.shields.io/badge/available%20on-deno.land/x-lightgrey.svg?logo=deno&labelColor=black )] ( https://github.com/sebastienfilion/[email protected] )
6
+ [ ![ deno version] ( https://img.shields.io/badge/deno-^1.4.6-lightgrey?logo=deno )] ( https://github.com/denoland/deno )
7
+ [ ![ GitHub release] ( https://img.shields.io/github/v/release/sebastienfilion/functional )] ( https://github.com/sebastienfilion/functional-http-server/releases )
8
+ [ ![ GitHub licence] ( https://img.shields.io/github/license/sebastienfilion/functional )] ( https://github.com/sebastienfilion/functional-http-server/blob/v0.1.1/LICENSE )
9
+
10
+ * [ Simple HTTP server] ( #simple-http-server )
11
+ * [ Routing] ( #routing )
2
12
3
13
## Simple HTTP server
4
14
@@ -9,7 +19,7 @@ function that takes a `Request` and return a `Task` of a `Response`.
9
19
``` js
10
20
import Task from " https://deno.land/x/[email protected] /library/Task.js" ;
11
21
import Response from " https://deno.land/x/[email protected] /library/Response.js" ;
12
- import startHTTPServer from " . /library/server.js" ;
22
+ import startHTTPServer from " https://deno.land/x/[email protected] /library/server.js" ;
13
23
14
24
startHTTPServer ({ port: 8080 }, request => Task .of (Response .OK ({}, request .raw )));
15
25
```
@@ -35,9 +45,9 @@ must return a `Task` of a `Response`.
35
45
36
46
``` js
37
47
import Task from " https://deno.land/x/[email protected] /library/Task.js" ;
48
+ import {
encodeText }
from " https://deno.land/x/[email protected] /library/utilities.js" ;
38
49
import Response from " https://deno.land/x/[email protected] /library/Response.js" ;
39
- import { route } from " ./library/route.js" ;
40
- import { encodeText } from " ./library/utilities.js" ;
50
+ import {
route }
from " https://deno.land/x/[email protected] /library/route.js" ;
41
51
42
52
startHTTPServer (
43
53
{ port: 8080 },
@@ -57,9 +67,9 @@ the assertion function. Each handler takes a `String` or a `RegExp` and a unary
57
67
58
68
``` js
59
69
import Task from " https://deno.land/x/[email protected] /library/Task.js" ;
70
+ import {
encodeText }
from " https://deno.land/x/[email protected] /library/utilities.js" ;
60
71
import Response from " https://deno.land/x/[email protected] /library/Response.js" ;
61
- import { handlers , route } from " ./library/route.js" ;
62
- import { encodeText } from " ./library/utilities.js" ;
72
+ import {
handlers ,
route }
from " https://deno.land/x/[email protected] /library/route.js" ;
63
73
64
74
startHTTPServer (
65
75
{ port: 8080 },
@@ -78,7 +88,7 @@ The binary function handler will be called with an object containing the origina
78
88
and other parameters; the second argument is the body of request serialized based on the content type.
79
89
80
90
``` js
81
- import { explodeRequest } from " . /library/utilities.js" ;
91
+ import {
explodeRequest }
from " https://deno.land/x/[email protected] /library/utilities.js" ;
82
92
83
93
startHTTPServer (
84
94
{ port: 8080 },
0 commit comments