Complete Examples
The /examples/spray-routing/ directory of the spray repository contains a number of example projects for spray-routing, which are described here.
on-spray-can
This examples demonstrates how to run spray-routing on top of the spray-can HTTP Server. It implements a very simple web-site and shows off various features like streaming, stats support and timeout handling.
Follow these steps to run it on your machine:
Clone the spray repository:
git clone git://github.com/spray/spray.git
Change into the base directory:
cd spray
Run SBT:
sbt "project on-spray-can" run
(If this doesn’t work for you your SBT runner cannot deal with grouped arguments. In this case you’ll have to run the commands project on-spray-can and run sequentially “inside” of SBT.)
Browse to http://127.0.0.1:8080/
Alternatively you can access the service with curl:
curl -v 127.0.0.1:8080/ping
Stop the service with:
curl -v 127.0.0.1:8080/stop
on-jetty
This examples demonstrates how to run spray-routing on top of spray-servlet. It implements a very simple web-site and shows off various features like streaming, stats support and timeout handling.
Follow these steps to run it on your machine:
Clone the spray repository:
git clone git://github.com/spray/spray.git
Change into the base directory:
cd spray
Run SBT:
sbt "project on-jetty" container:start shell
Browse to http://127.0.0.1:8080/
Alternatively you can access the service with curl:
curl -v 127.0.0.1:8080/ping
Stop the service with:
container:stop
simple-routing-app
This examples demonstrates how to use the SimpleRoutingApp trait.
Follow these steps to run it on your machine:
Clone the spray repository:
git clone git://github.com/spray/spray.git
Change into the base directory:
cd spray
Run SBT:
sbt "project simple-routing-app" run
(If this doesn’t work for you your SBT runner cannot deal with grouped arguments. In this case you’ll have to run the commands project simple-routing-app and run sequentially “inside” of SBT.)
Browse to http://127.0.0.1:8080/
Alternatively you can access the service with curl:
curl -v 127.0.0.1:8080/ping
Stop the service with:
curl -v 127.0.0.1:8080/stop