Skip to main content

module Content


import Content;


Content provides access to the content server of the Rascal terminal for viewing interactive HTML output.

function html

Content html(str html)


Directly serve a static html page

function file

Content file(loc src)


Directly serve the contents of a file

function plainText

Content plainText(str text)


Directly serve the contents of a string as plain text

alias Body

value (type[value] expected)

data Request

data Request (map[str, str] headers = (), map[str, str] parameters = (), map[str,str] uploads = ()) 
= get (str path)
| put (str path, Body content)
| post(str path, Body content)
| delete(str path)
| head(str path)


Request values represent what a browser is asking for, most importantly the URL path.


A request value also contains the full HTTP headers, the URL parameters as a map[str,str] and possibly uploaded content, also coded as a map[str,str]. From the constructor type, put or get you can see what kind of HTTP request it was.


  • Note that put and post have not been implemented yet in the REPL server.

data Response

data Response  
= response(Status status, str mimeType, map[str,str] header, str content)
| fileResponse(loc file, str mimeType, map[str,str] header)
| jsonResponse(Status status, map[str,str] header, value val, str dateTimeFormat = "yyyy-MM-dd\'T\'HH:mm:ss\'Z\'")


A response encodes what is send back from the server to the browser client.


The three kinds of responses, encode either content that is already a str, some file which is streamed directly from its source location or a jsonResponse which involves a handy, automatic, encoding of Rascal values into json values.

function response

Response response(str content, map[str,str] header = ())

Response response(Status status, str explanation, map[str,str] header = ())


Utility to quickly render a string as HTML content

function plain

Response plain(str text)


Utility to quickly make a plaintext response.

function response

Response response(loc f, map[str,str] header = ())

default Response response(value val, map[str,str] header = ())


Utility to serve a file from any source location.

data Status

data Status  
= ok()
| created()
| accepted()
| noContent()
| partialContent()
| redirect()
| notModified()
| badRequest()
| unauthorized()
| forbidden()
| notFound()
| rangeNotSatisfiable()
| internalError()


Encoding of HTTP status