Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added Clack.Handler.

  • Loading branch information...
commit bdcc9c55742fa04cdea6b6affa03f2273a80f8be 1 parent 05d309d
@fukamachi authored
Showing with 54 additions and 13 deletions.
  1. +3 −1 clack.asd
  2. +13 −12 src/core/clack.lisp
  3. +38 −0 src/core/handler.lisp
View
4 clack.asd
@@ -61,7 +61,9 @@
(:file "response")
(:file "component")
(:file "middleware" :depends-on ("component"))
- (:module "handler"
+ (:file "handler")
+ (:module "handlers"
+ :pathname "handler"
:depends-on ("component")
:components
((:file "hunchentoot")
View
25 src/core/clack.lisp
@@ -17,9 +17,13 @@
:<middleware>
:call-next
:wrap)
+ (:import-from :clack.handler
+ :<handler>
+ :stop)
(:import-from :clack.util
:find-handler)
- (:export :<component>
+ (:export :stop
+ :<component>
:<middleware>
:call
:call-next
@@ -42,20 +46,17 @@ Example:
@export
(defun clackup (app &key (server :hunchentoot) (port 5000) (debug t))
(prog1
- (let ((handler (find-handler server)))
- (funcall (intern "RUN" handler)
- app
- :port port
- :debug debug))
+ (let ((handler-package (find-handler server)))
+ (make-instance '<handler>
+ :server-name server
+ :acceptor
+ (funcall (intern "RUN" handler-package)
+ app
+ :port port
+ :debug debug)))
(format t "~&~:(~A~) server is started.~
~%Listening on localhost:~A.~%" server port)))
-@export
-(defun stop (handler &key (server :hunchentoot))
- "Stop Clack server. Currently works only Hunchentoot."
- (let ((handler-package (find-handler server)))
- (funcall (intern "STOP" handler-package) handler)))
-
(doc:start)
@doc:NAME "
View
38 src/core/handler.lisp
@@ -0,0 +1,38 @@
+#|
+ This file is a part of Clack package.
+ URL: http://github.com/fukamachi/clack
+ Copyright (c) 2011 Eitarow Fukamachi <e.arrows@gmail.com>
+
+ Clack is freely distributable under the LLGPL License.
+|#
+
+(clack.util:namespace clack.handler
+ (:use :cl)
+ (:import-from :clack.util
+ :find-handler))
+
+(cl-annot:enable-annot-syntax)
+
+@export
+(defclass <handler> ()
+ ((server-name :type keyword
+ :initarg :server-name
+ :accessor server-name)
+ (acceptor :initarg :acceptor
+ :accessor acceptor)))
+
+@export
+(defmethod stop ((this <handler>))
+ "Stop Clack server. Currently works only Hunchentoot."
+ (let ((handler-package (find-handler (server-name this))))
+ (funcall (intern "STOP" handler-package) (acceptor this))))
+
+(doc:start)
+
+@doc:NAME "
+Clack.Handler - Class for Handler
+"
+
+@doc:AUTHOR "
+* Eitarow Fukamachi (e.arrows@gmail.com)
+"
Please sign in to comment.
Something went wrong with that request. Please try again.