Skip to content

duct-framework/handler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Duct Handler Build Status

A library that provides common Ring handlers for the Duct framework.

Installation

Add the following dependency to your deps.edn file:

org.duct-framework/handler {:mvn/version "0.1.1"}

Or to your Leiningen project file:

[org.duct-framework/handler "0.1.1"]

Usage

This library provides three Integrant keys that initiate into Ring handlers.

:duct.handler/static creates a handler that always returns the same response map. The value of this key is the response map itself.

:duct.handler/file and :duct.handler/resource are handlers that return files or resources. They take two options:

  • :paths - a map of paths strings to an option map
  • :not-found - a response map to be returned if no path matches

If the :not-found option is not supplied, nil is returned from the handler (which can be useful for trying multiple handlers to see which matches).

The options mapped from each path go directly to the ring.util.reponse/file-response and ring.util.response/resource-response functions.

For example:

{:duct.handler/file
 {"/" {:root "public"}
  "/js" {:root "target/js"}}}

License

Copyright © 2024 James Reeves

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published