:decorators

52 views
Skip to first unread message

Frank

unread,
Apr 7, 2013, 4:03:54 AM4/7/13
to res...@googlegroups.com
Hello,

I'm reading through the documentation and was trying that decorators auth example.
Trying to attach that proxy-route via the :decorators keyword signals an exception.
However it seems that this declaration goes now into the body, can you confirm this?

What I got is this:

(defclass http-auth-route (routes:proxy-route) ())                                                                            

(defmethod routes:route-check-conditions ((route http-auth-route) bindings)                                                   
  (and (call-next-method)                                                                                                     
       (multiple-value-bind (u p) (hunchentoot:authorization)                                                                 
         (or (and (string= u "foo")                                                                                           
                  (string= p "bar"))                                                                                          
             (hunchentoot:require-authorization)))))                                                                          

(defun @http-auth-require (route)                                                                                             
  (make-instance 'http-auth-route :target route))                                                                             

;;; Signals exception
(restas:define-route manufacturers ("manufacturers" :method :get                                                              
                                                    :decorators '(@http-auth-require))                                         
  ;; Code here
)

Andrey Moskvitin

unread,
Apr 7, 2013, 12:55:10 PM4/7/13
to res...@googlegroups.com
Hi,

Yes, the syntax of defroute changed. Now, instead of parameters, use the
declarations:

(restas:define-route manufacturers ("manufacturers" :method :get)
  (:decorators '@http-auth-require)
  ;; Code here
)

Andrey

2013/4/7 Frank <frank....@gmail.com>

--
You received this message because you are subscribed to the Google Groups "restas" group.
To unsubscribe from this group and stop receiving emails from it, send an email to restas+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Alok Thapa

unread,
Jun 3, 2013, 4:09:03 PM6/3/13
to res...@googlegroups.com
Hi Andrey,

I also updated my project to the latest version of restas and I'm getting the same error. But even with your example I get an error that says "The value NIL is not of type HASH-TABLE". I have copied the backtrace from slime below, can you help?


The value NIL is not of type HASH-TABLE.
   [Condition of type TYPE-ERROR]

Restarts:
 0: [RETRY] Retry SLIME REPL evaluation request.
 1: [*ABORT] Return to SLIME's top level.
 2: [ABORT] Abort thread (#<THREAD "repl-thread" RUNNING {10052D0113}>)

Backtrace:
  0: (SB-IMPL::GETHASH3 :EXPORT-ROUTE-SYMBOLS NIL NIL)[:EXTERNAL]
      Locals:
        SB-DEBUG::ARG-0 = 3
        SB-DEBUG::ARG-1 = :EXPORT-ROUTE-SYMBOLS
        SB-DEBUG::ARG-2 = NIL
        SB-DEBUG::ARG-3 = NIL
  1: (RESTAS::REGISTER-ROUTE-TRAITS MANUFACTURERS #<HASH-TABLE :TEST EQL :COUNT 4 {1002B1FD23}>)
      Locals:
        SB-DEBUG::ARG-0 = MANUFACTURERS
        SB-DEBUG::ARG-1 = #<HASH-TABLE :TEST EQL :COUNT 4 {1002B1FD23}>
  2: (SB-INT:SIMPLE-EVAL-IN-LEXENV (RESTAS::REGISTER-ROUTE-TRAITS 'MANUFACTURERS (ALEXANDRIA.0.DEV:PLIST-HASH-TABLE (LIST :TEMPLATE "manufacturers" :METHOD :GET :DECORATORS ...))) #<NULL-LEXENV>)

Andrey Moskvitin

unread,
Jun 3, 2013, 4:34:02 PM6/3/13
to res...@googlegroups.com
Hi,

I think you should remove old fasl-files and recompile the project.

Andrey


2013/6/4 Alok Thapa <i.g...@gmail.com>

Alok Thapa

unread,
Jun 8, 2013, 8:03:52 PM6/8/13
to res...@googlegroups.com
Hi Andrey,

I tried the new code in a fresh installation of restas from quicklisp and from github and I still get the same error. 

Here's the code that I am using ->

(defclass auth-route (routes:proxy-route) ())

(defun @auth-route (route)
  (make-instance 'auth-route :target route))

(restas:define-route main ("" :method :get)
                                     (:decorators '@auth-route)
   "hello world")

Also, can you please update the documentation so that I know what it should look like? 

Thanks again,

Alok

Andrey Moskvitin

unread,
Jun 9, 2013, 11:12:11 AM6/9/13
to res...@googlegroups.com
Hi,

I don't know what is your problem:( It works for my system.

> Also, can you please update the documentation so that I know what it
> should look like?

Unfortunately, I don't still have any free time for it.

Andrey


2013/6/9 Alok Thapa <i.g...@gmail.com>
Reply all
Reply to author
Forward
0 new messages