-
Notifications
You must be signed in to change notification settings - Fork 0
tildedave/restmock
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
# restmock restmock is a server that serves mostly static content. This content is determined by a config file external to the server; restmock reads this config file and generates a handler based off of it. ## Usage Put your config file and any files that will be served by restmock in $CONFIG_LOCATION. This location will need to be on your classpath when you run the server to be visible. lein deps lein uberjar java -classpath $CONFIG_LOCATION:./restmock-1.0.0-SNAPSHOT-standalone.jar restmock.core --config <default config.xml> --port <default 5000> Because of how java -jar works (sets classpath to that in the Manifest), it is not possible to run restmock with java -jar and still have it properly read the configuration. In the true Clojure way, configuration is specified by a DSL. There are a few imporant concepts for configuration: * A route is a possible matcher for a request. It contains a request matcher and a response. * A request matcher is a set of criteria that, if true, will activate the response. * A response is the response that will be returned to the client. This can be static XML/JSON or static text. The following is an example config file: (routes (route "Hello, world!" (request (uri "/hello")) (response (text "Hello, world!"))) (route "Can retrieve all the kittens" (request (uri "/kittens") (method :get)) (response (text "Some adorable kittens!"))) (route "Can't make a new kitten" (request (uri "/kittens") (method :post)) (response (status 422))) (route "Can update a kitten" (request (uri "/kittens/([0-9]+)") (method :put)) (response (status 202))) (route "Person XML" (request (uri "/person/([0-9]+)")) (response (file "person.xml")))) Files specified by your configuration also need to be accessible from your classpath. ## Changes in 1.0 * Initial release ## Changes in 1.1 * Rewrite configuration to be DSL based. ## License Copyright (C) 2010 Dave King <tildedave@gmail.com> Distributed under the Eclipse Public License, the same as Clojure.
About
Mock RESTful server for serving mostly static content for testing clients
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published