Permalink
Browse files

add a separated system for examples

  • Loading branch information...
1 parent cda5c38 commit 7c6a628d56af411de7a46432cc2bd890011a3fc7 @galdor galdor committed Nov 6, 2010
Showing with 54 additions and 30 deletions.
  1. +3 −3 .gitignore
  2. 0 { → examples}/config.conf
  3. +4 −0 examples/packages.lisp
  4. +20 −0 examples/test.lisp
  5. +10 −0 m2cl-examples.asd
  6. +3 −2 m2cl.asd
  7. +0 −4 packages.lisp
  8. +1 −0 setup.sh
  9. 0 { → src}/m2cl.lisp
  10. +13 −0 src/packages.lisp
  11. +0 −21 test.lisp
View
@@ -1,5 +1,5 @@
*.fasl
-/config.sqlite
-/logs
-/run
+/examples/config.sqlite
+/examples/logs
+/examples/run
File renamed without changes.
@@ -0,0 +1,4 @@
+
+(defpackage :m2cl-examples
+ (:use :cl)
+ (:export :run-test))
View
@@ -0,0 +1,20 @@
+
+(in-package :m2cl-examples)
+
+(defun run-test ()
+ (m2cl:with-handler (handler "dev" "tcp://127.0.0.1:8090" "tcp://127.0.0.1:8091")
+ (loop
+ (process-request handler (m2cl:handler-receive-json handler)))))
+
+(defun process-request (handler request)
+ (format t "~&message~%")
+ (format t " sender: ~A~%" (m2cl:request-sender request))
+ (format t " connection-id: ~A~%" (m2cl:request-connection-id request))
+ (format t " path: ~A~%" (m2cl:request-path request))
+ (format t " headers:~%")
+ (dolist (header (m2cl:request-headers request))
+ (format t " ~A: ~A~%" (car header) (cdr header)))
+ (format t " body: ~A~%" (m2cl:request-body request))
+ (format t " data: ~A~%" (m2cl:request-data request))
+ (m2cl:handler-reply-http handler request (format nil "{}~%")
+ :headers '(("Content-Type" . "text/javascript"))))
View
@@ -0,0 +1,10 @@
+
+(defsystem m2cl-examples
+ :name "m2cl-examples"
+ :author "Nicolas Martyanoff"
+ :license "BSD"
+ :description "Examples for the m2cl mongrel2 handler."
+ :depends-on (:m2cl)
+ :components ((:module "examples"
+ :components ((:file "packages")
+ (:file "test" :depends-on ("packages"))))))
View
@@ -5,5 +5,6 @@
:license "BSD"
:description "A handler for the mongrel2 HTTP server."
:depends-on (:cl-json :cl-ppcre :zeromq)
- :components ((:file "packages")
- (:file "m2cl" :depends-on ("packages"))))
+ :components ((:module "src"
+ :components ((:file "packages")
+ (:file "m2cl" :depends-on ("packages"))))))
View
@@ -1,4 +0,0 @@
-
-(defpackage :m2cl
- (:use :cl)
- (:export))
View
@@ -1,4 +1,5 @@
#!/bin/sh
+cd examples
mkdir -p run logs
m2sh load -db config.sqlite -config config.conf
File renamed without changes.
View
@@ -0,0 +1,13 @@
+
+(defpackage :m2cl
+ (:use :cl)
+ (:export :request-sender :request-connection-id :request-path
+ :request-headers :request-body :request-data
+ :request-header
+
+ :with-handler
+ :handler-receive :handler-receive-json
+ :handler-reply :handler-reply-http :handler-reply-json
+ :handler-close
+ :handler-deliver :handler-deliver-http :handler-deliver-json
+ :handler-deliver-close))
View
@@ -1,21 +0,0 @@
-
-(in-package :m2cl)
-
-(defun run-test ()
- (with-handler (handler "dev" "tcp://127.0.0.1:8090" "tcp://127.0.0.1:8091")
- (loop
- (process-request handler (handler-receive-json handler)))))
-
-(defun process-request (handler request)
- (with-slots (sender connection-id path headers body data) request
- (format t "~&message~%")
- (format t " sender: ~A~%" sender)
- (format t " connection-id: ~A~%" connection-id)
- (format t " path: ~A~%" path)
- (format t " headers:~%")
- (dolist (header headers)
- (format t " ~A: ~A~%" (car header) (cdr header)))
- (format t " body: ~A~%" body)
- (format t " data: ~A~%" data))
- (handler-reply-http handler request (format nil "{}~%")
- :headers '(("Content-Type" . "text/javascript"))))

0 comments on commit 7c6a628

Please sign in to comment.