Next: Function index, Previous: Introduction, Up: Top
CLAW wraps the Hunchentoot (see: unchentoot), a wonderful as powerful web server written in Common Lisp,
into the CLAWSERVER
class.
As an Hunchentoot wrapper CLAWSERVER
“provides facilities like automatic session handling (with and without cookies), logging
(to Apache's log files or to a file in the file system), customizable error handling, and easy access to GET and POST parameters sent by the client.”
CLAWSERVER
is not only a Hunchentoot wrapper, it is also the common place where you put your web applications
built with CLAW into lisplet that you can see as application resource containers and request dispatchers.
CLAWSERVER
instance initializationWhen you want to instantiate a CLAWSERVER
class, remember that it accepts the following initialization arguments:
CLAWSERVER
class methodsclawserver-port obj
(setf clawserver-port) val obj
CLAWSERVER
instance
clawserver-sslport obj
(setf clawserver-sslport) val obj
CLAWSERVER
instance
clawserver-address obj
(setf clawserver-address) val obj
CLAWSERVER
instance
NIL
=> any).
If the server is started and you try to change the listening value an error will be signaled
clawserver-name obj
(setf clawserver-name) val obj
CLAWSERVER
instance
clawserver-sslname obj
(setf clawserver-sslname) val obj
CLAWSERVER
instance
clawserver-mod-lisp-p obj
(setf clawserver-mod-lisp-p) val obj
CLAWSERVER
instance
NIL
), the server will act as a back-end for mod_lisp, otherwise it will be a stand-alone web server.
If the server is started and you try to change the listening value an error will be signaled
clawserver-use-apache-log-p obj
(setf clawserver-use-apache-log-p) val obj
CLAWSERVER
instance
NIL
. (default T
if mod_lisp
is activated.
If the server is started and you try to change the listening value an error will be signaled
clawserver-input-chunking-p obj
(setf clawserver-input-chunking-p) val obj
CLAWSERVER
instance
T
)
If the server is started and you try to change the listening value an error will be signaled
clawserver-read-timeout obj
(setf clawserver-read-timeout) val obj
CLAWSERVER
instance
T
)
(default to HUNCHENTOOT:*DEFAULT-READ-TIMEOUT* [20 seconds]).
If the server is started and you try to change the listening value an error will be signaled
clawserver-write-timeout obj
(setf clawserver-write-timeout) val obj
CLAWSERVER
instance
T
)
(default to HUNCHENTOOT:*DEFAULT-WRITE-TIMEOUT* [20 seconds]).
If the server is started and you try to change the listening value an error will be signaled
clawserver-setuid obj
(setf clawserver-setuid) val obj
CLAWSERVER
instance
clawserver-setgid obj
(setf clawserver-setgid) val obj
CLAWSERVER
instance
clawserver-ssl-certificate-file obj
(setf clawserver-ssl-certificate-file) val obj
CLAWSERVER
instance
CLAWSERVER
is SSL enabled
If the server is started and you try to change the listening value an error will be signaled
clawserver-ssl-privatekey-file obj
(setf clawserver-ssl-privatekey-file) val obj
CLAWSERVER
instance
CLAWSERVER
is SSL enabled
If the server is started and you try to change the listening value an error will be signaled
clawserver-ssl-privatekey-password obj
(setf clawserver-ssl-privatekey-password) val obj
CLAWSERVER
instance
CLAWSERVER
is SSL enabled
If the server is started and you try to change the listening value an error will be signaled
clawserver-start obj
CLAWSERVER
instance
CLAWSERVER
begin to dispatch requests
clawserver-stop obj
CLAWSERVER
instance
CLAWSERVER
stop.
clawserver-register-lisplet clawserver lisplet-obj
CLAWSERVER
instance
LISPLET
class instance
LISPLET
, that is an `application container` for request dispatching.
clawserver-unregister-lisplet clawserver lisplet-obj
CLAWSERVER
instance
LISPLET
class instance
LISPLET
, that is an `application container`, an so all it's resources, from the CLAWSERVER
instance.
Starting CLAW is very easy and requires a minimal effort. CLAW supports both http and https protocols, thought enabling SSL connection for CLAW requires a little more work then having it responding only to http calls.
To simply start CLAW server, without enabling SSL requests handling, you just need few steps:
(defparameter *clawserver* (make-instance 'clawserver)) (clawserver-start *clawserver*) |
This will start the web server on port 80 that is the default.
Of course you can create a parametrized version of CLAWSERVER
instance for example specifying the listening port as the following:
(defparameter *clawserver* (make-instance 'clawserver :port 4242)) (clawserver-start *clawserver*) |
To enable CLAW to https firt you need a certificate file. A quick way to get one on a Linux system is to use openssl to generate the a certificate PEM file, the following example explains how to do.
Firstly you'll generate the private key file:
#> openssl genrsa -out privkey.pem 2048Generating RSA private key, 2048 bit long modulus ............................+++ ..................................................+++ e is 65537 (0x10001)#> |
Then the certificate file:
#> openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]:IT State or Province Name (full name) [Some-State]: bla-bla Locality Name (eg, city) []: bla-bla Organization Name (eg, company) [Internet Widgits Pty Ltd]: mycompany Organizational Unit Name (eg, section) []: Common Name (eg, YOUR name) []:www.mycompany.com Email Address []:admin@mycompany.com#> |
Now you can start CLAWSERVER
in both http and https mode:
(defparameter *clawserver* (make-instance 'clawserver :port 4242 :sslport 4443 :ssl-certificate-file #P"/path/to/certificate/cacert.pem" :ssl-privatekey-file #P"/path/to/certificate/privkey.pem"))) (clawserver-start *clawserver*) |
CLAW is now up and you can browse it with your browser using address http://www.yourcompany.com:4242 and http://www.yourcompany.com:4443. Of course you will have only a 404 response page!