-
Notifications
You must be signed in to change notification settings - Fork 0
/
leonardo.ol
55 lines (44 loc) · 1.27 KB
/
leonardo.ol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from console import Console
from file import File
from string_utils import StringUtils
from protocols.http import DefaultOperationHttpRequest
interface HTTPInterface {
RequestResponse:
get(DefaultOperationHttpRequest)(undefined)
}
type Params {
location: string
documentDir: string
}
service Leonardo(p: Params) {
embed Console as Console
embed File as File
embed StringUtils as StringUtils
execution { concurrent }
inputPort HTTPInput {
protocol: http {
.keepAlive = false;
.debug = false;
.debug.showContent = false;
.format -> format;
.contentType -> mime;
.default = "get"
}
location: p.location
interfaces: HTTPInterface
}
main {
[get(request)(response) {
scope(scope_get) {
install(FileNotFound => println@Console("File not found: " + file.filename)());
s = request.operation
s.regex = "\\?";
split@StringUtils( s )( s );
file.filename = p.documentDir + s.result[0];
file.format = "text"
format = "html"
readFile@File(file)(response)
}
} ] { nullProcess }
}
}