Resources that can be grouped into the http:server resource must have that prefix. Grouping is basically hierarchical, and without that common prefix, it means we'd have to special-case our grouping algorithm.
38 lines
947 B
Plaintext
38 lines
947 B
Plaintext
import "value"
|
|
|
|
http:server ":8080" { # by default http uses :80 but using :8080 avoids needing root!
|
|
#address => ":8080", # you can override the name like this
|
|
#timeout => 60, # add a timeout (seconds)
|
|
}
|
|
|
|
# you can add a raw file like this...
|
|
http:server:file "/file1" {
|
|
data => "hello, world, i'm file1 and i don't exist on disk!\n",
|
|
}
|
|
|
|
# wget --post-data 'key=hello&whatever=bye' -O - http://127.0.0.1:8080/flag1
|
|
http:server:flag "/flag1" {
|
|
#server => ":8080",
|
|
key => "key",
|
|
}
|
|
value "value1" {
|
|
any => "tmp", # can be any type
|
|
}
|
|
print "print1" {
|
|
Meta:autogroup => false,
|
|
}
|
|
|
|
Http:Server:Flag["/flag1"].value -> Print["print1"].msg
|
|
Http:Server:Flag["/flag1"].value -> Value["value1"].any
|
|
|
|
$ret = value.get_str("value1") # name of value resource
|
|
$val = $ret->value
|
|
test "get" {
|
|
anotherstr => $val,
|
|
onlyshow => ["AnotherStr",], # displays nicer
|
|
}
|
|
file "/tmp/file" {
|
|
state => $const.res.file.state.exists,
|
|
content => "value: ${val}\n",
|
|
}
|