0.2.2 • Published 4 years ago

downstream-server v0.2.2

Weekly downloads
42
License
-
Repository
-
Last release
4 years ago

Downstream Server

A cross-application server system designed for simple content servers.

Upcoming features

  • HTTPS support
  • HTTP header read/write access
  • Reusable behaviours

Example Server

Create a provider.dsp file and add the following:

[/] => pass "<h1>Hello World!</h1>"

Then run: down-serve and visit "localhost"

Basic Syntax

Global Syntax

Comments are denoted by a //

Variables are accessed by an @, and can be reference as pointers with &.

Stream declaration

URL handlers are denoted by [...], and can contain a valid URL and variables.

[/test/@var/item]

All streams require a behaviour.

Behaviours

Behaviours are declare with an =>. Behaviours consist of actions, which are separated by ->.

=> log "This is a test" -> pass "Hello world!"

Config

There are two types of configuration, environment config, and external commands

Environment config

config name value

Here's a full list of configurations, More will be added soon:

root : The directory to start in for file loading

showErrors : Controls whether errors are returned

httpPort : The HTTP port to listen on, defaults to 80

External declerations

Downstream supports calling terminal commands in place of built-in methods.

extern cli_command method_name

Using an external command is identically to a built-in method.

... -> my_command arg1 arg2 -> ...

Method Reference

! : Denotes a breakpoint, this will halt execution and print out the current context. Execution will resume when return is pressed in the host console.

log ...value : Writes text to the host console.

pass body : Sets the response body value.

decodeURI uri : Decodes a given URI. Example: "Hello%20World!" becomes "Hello World!"

put &variable : Inserts the response body into a variable pointer.

readFile filename : Inserts the contents of a file into the response body.

populate : Allows for the inserting of variables into the response body. Example <h1>@title</h1> become <h1>Test</h1> where @title is Test.

split delimiter ...pointers : Splits the response body by the delimiter and maps the results to the pointers given.

0.2.1

4 years ago

0.2.2

4 years ago

0.1.11

4 years ago

0.1.10

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago