Giter Club home page Giter Club logo

ring-server's Introduction

Ring-Server

A library for starting a web server to serve a Ring handler with sensible default options and environment variable overrides.

Features

When starting in development mode (i.e. LEIN_NO_DEV is not set):

  • The server finds a free port to start on
  • It automatically reloads changed files
  • It renders exceptions and their stacktraces in HTML
  • A web browser is automatically opened to the started server

In production:

  • You can specify the port via the PORT environment variable
  • You can add hooks to run on startup and shutdown.

Install

Add the following dependency to your project.clj file:

[ring-server "0.2.8"]

Usage

Simple usage:

(use 'ring.server.standalone)
(serve your-handler)

You can also specify a map of options:

(serve your-handler {:port 4040})

The following options are supported:

  • :port - The port to start the server on, overrides $PORT

  • :join? - Whether to wait until the server stops (default true)

  • :init - A function executed when the server starts

  • :destroy - A function executed when the server stops

  • :open-browser? - True if you want a browser to be opened to the server. Defaults to true in development mode, false in production mode.

  • :browser-uri - A path to append to the target URL if opening a browser (default none). The full URI will be constructed like: http://{host}:{port}{browser-uri}

  • :stacktraces? - True if you want a stacktrace to be displayed in the browser when an exception is raised. Default to true in development, false in production.

  • :auto-reload? - True if you want your source files to be automatically reloaded when they are modified. Defaults to true in development, false in production.

  • :reload-paths - A seq of source paths to reload. Defaults to ["src"]. Only relevant if :auto-reload? is true.

  • :auto-refresh? - True if you want your browser to automatically refresh when source files are changed. Defaults to false.

License

Copyright (C) 2012 James Reeves

Distributed under the Eclipse Public License, the same as Clojure.

ring-server's People

Contributors

weavejester avatar edtsech avatar joelittlejohn avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.