Skip to content

fukamachi/myway

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

My Way

My Way is a Sinatra-compatible URL routing library. This was originally written as Clack.Util.Route, a part of Clack.

Usage

(use-package :myway)

(defvar *mapper* (make-mapper))

(connect *mapper* "/" "Welcome to My Way.")

(connect *mapper* "/hello/?:name?"
         (lambda (params)
           (format nil "Hello, ~A" (or (getf params :name)
                                       "Guest"))))

(dispatch *mapper* "/")
;=> "Welcome to My Way."
;   T

(dispatch *mapper* "/hello")
;=> "Hello, Guest"
;   T

(dispatch *mapper* "/hello/Eitaro")
;=> "Hello, Eitaro"
;   T

(dispatch *mapper* "/hello/Eitaro" :method :POST)
;=> NIL
;   NIL

next-route

(connect *mapper* "/guess/:who"
         (lambda (params)
           (if (string= (getf params :who) "Eitaro")
               "You got me!"
               (next-route))))

(connect *mapper* "/guess/*"
         (lambda (params)
           (declare (ignore params))
           "You missed!"))

to-app

to-app makes a Clack app from mapper.

(to-app *mapper*)
;=> #<CLOSURE (LAMBDA (MYWAY::ENV) :IN TO-APP) {100E24F13B}>

(clack:clackup (to-app *mapper*))

Installation

(ql:quickload :myway)

Author

Copyright

Copyright (c) 2014 Eitaro Fukamachi (e.arrows@gmail.com)

License

Licensed under the LLGPL License.

About

Sinatra-compatible URL routing library for Common Lisp

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •