hello-world-web

A simple website that displays "Hello World!".

This introduces the modular.ring/WebRequestHandler protocol which provides an integration surface between a Ring-compatible web server (e.g. Jetty, http-kit) and a Ring handler.

In most applications, the choice of web server is made ahead of time and some code is written to provide the web server with the handler to call. In this example, the relationship between the web server and Ring handler is made via a dependency declaration between the web server (in this case, http-kit) and the handler.

In the system.clj we see two components: :http-listener-listener and :hello-world-website-handler. The first component declares a dependency on a request handler, with the using clause. The new-dependency-map function returns a map that satisfies the web server comonent's :request-handler dependency with our application component hello-world-web.hello-world-website/HelloWorldHandler. This component must satisfy the modular.ring/WebRequestHandler protocol. This pattern of using protocols to provide the integration surface between components is used throughout modular.

Incantation

To create a project called foo based on this template, type this in a command line shell :-

lein new modular foo hello-world-web

Modules

component

http-listener

hello-world-website

Components

modular.http-kit/webserver

Additional libraries

[com.stuartsierra/component "0.2.2"]

Custom files

src/foo/hello_world_website.clj


Modularity
Copyright © 2015, LTD.