pod wisp
Wisp web Server
Mixins
WispSessionStore |
Pluggable hooks for Wisp session storage. |
Classes
WispDefaultErrMod |
WispDefaultErrMod |
WispService |
Simple web server services HTTP/HTTPS requests to a top-level root WebMod. |
Wisp web Server
WispSessionStore |
Pluggable hooks for Wisp session storage. |
WispDefaultErrMod |
WispDefaultErrMod |
WispService |
Simple web server services HTTP/HTTPS requests to a top-level root WebMod. |
Fantom comes bundled with the WispService
which implements a web server purely in Fantom code - so you can use it without the fuss of setting up additional software.
You can run a test wisp server straight from fansh using a configurable port:
fansh> wisp::WispService { httpPort = 8080 }.start fan.wisp.WispService@5a9de6 [16:22:49 30-Nov-09] [info] [web] http started on port 8080
If it is running correctly you should be able to hit http://localhost:8080/ and see the test page.
Wisp is easily configured by installing a root WebMod which is responsible for serving all requests to the server. Typically you will install a composition WebMod to setup your pipeline and routing configuration.
See the following examples for how to setup a daemon script with various WebMod configurations:
Wisp can be configured to serve HTTPS connection by setting the https port with the -httpsPort
option. Wisp requires a keystore to serve https connections. A keystore is a repository of security certificates (either authorization or public key certificates) that can be used for TLS encryption. The keystore should contain the public and private key for your web server.
Wisp uses the following conventions for loading the keystore:
keystore.p12
etc/inet/keystore.p12
of your Fantom installationJava provides a utility called keytool
that can be used for generating and managing keystore files. For testing purposes, you can create a self-signed certificate and add it to a new pkcs12 keystore using the following command (make sure to use "changeit" as the password when prompted):
$ keytool -genkey \ -alias my.domain.com \ -keyalg RSA \ -storetype pkcs12 \ -keystore /path/to/etc/inet/keystore.p12
The following article contains many useful examples of working with keystores. The examples all use the JKS keystore format, so make sure to add the -storetype pkcs12
option if you attempt to duplicate any of the commands.
If you have a JKS formatted keystore, you can convert it to PKCS12 using the following command:
$ keytool -importkeystore \ -srckeystore keystore.jks \ -srcalias my.domain.com \ -destkeystore keystore.p12 \ -deststoretype PKCS12
For the common case where a single WebMod is used, wisp can be run directly from the command line:
$ fan wisp Usage: wisp [options] <mod> Arguments: mod qualified type name for WebMod to run Options: -help, -? Print usage help -addr <Str> IP address to bind to -httpPort <Int> IP port to bind for HTTP (default 8080) -httpsPort <Int> IP port to bind for HTTPS (disabled unless set)
For example:
$ fan wisp myPod::MyWebMod [16:43:16 17-Jul-15] [info] [web] http started on port 8080