rwserve-lorem-ipsum v1.0.9
Open Source RWSERVE plugin
Lorem Ipsum
Dolor sit amet
Motivation
When developing a new plugin it's necessary to test the working functionality with payloads of various sizes. The data in the payload itself has no particular meaning, only it's presence or absence.
Sometimes these tests work best when the payload is deterministic: where the data and its length are repeatable. Other tests work better when the payload is random in length and value.
This plugin generates a response body either deterministically or randomly based on settings provided in the configuration file, or through query-string variables.
Customization
Classic Lorem Ipsum is the default text for the payload, but custom text can be specified when necessary.
This plugin is open source and can be used as is, or enhanced to provide additional features, such as:
- Obtaining custom text from data sources on the server.
- Generating payloads in additional languages. (See ISO-639-3 for "tlh").
Download
The plugin module is available from NPM
. Before proceeding, you should already have Node.js and RWSERVE configured and
tested.
This module should be installed on your web server in a well-defined place, so
that it can be discovered by RWSERVE. The standard place for public domain
plugins is /srv/rwserve-plugins.
Configuration is Everything
Make the software available by declaring it in the plugins section of your
configuration file. For detailed instructions on how to do this, refer to the plugins
documentation on the Read Write Tools HTTP/2 Server website.
TL;DR
The config settings are straightforward:
custom-textis the Lorem Ipsum to use in the payload.repeatis the number of times the text should be repeated.randomizeis "true" or "false".content-typeis the MIME-type identifier to add to the response headers.
When randomize is "false" the same payload is generated each time.
When custom-text is omitted, and randomize is "true" the payload will consist of
an arbitrary selection of classic "sentences".
When custom-text is provided, and randomize is "true" the text is split into
words and rearranged to provide an arbitrary selection of words.
When content-type is omitted, no "content-type" header is added to the response.
The sample router shown above will route any GET or HEAD request for the virtual
resource /lorem-ipsum, to the plugin.
Cookbook
A full configuration file with typical settings for a server running on
localhost port 7443, is included in this NPM module at etc/lorem-ipsum-config.
To use this configuration file, adjust these variables if they don't match your
server setup:
Runtime overrides
Sometimes it is desirable to override the settings provided in the configuration file on a request-by-request basis. This can be done by providing the values as query string variables. To do this, use the identical names as above, being sure to urlencode the custom text. For example:
Deployment
Once you've tested the plugin and are ready to go live, adjust your production
web server's configuration in /etc/rwserve/rwserve.conf and restart it using systemd
. . .
. . . then monitor its request/response activity with journald.
Prerequisites
This is a plugin for the Read Write Tools HTTP/2 Server, which works on Linux platforms.
Review
License
The rwserve-lorem-ipsum plugin is licensed under the MIT License.