Changeset 25369 in project


Ignore:
Timestamp:
10/14/11 14:27:43 (9 years ago)
Author:
Mario Domenech Goulart
Message:

awful: the method' keyword parameter for define-page' and `ajax' & friends can be bound to a list of methods. Methods are now case insensitive.

Location:
release/4/awful
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/4/awful/extra/doc/procedures

    r25070 r25369  
    221221requested path.
    222222
    223 {{method}} (a symbol) indicates the HTTP method to be used (e.g.,
    224 {{GET}}, {{POST}}, {{PUT}}).  Pages that use different methods can use
    225 the same path.
     223{{method}} (a symbol or a list) indicates the HTTP method to be used
     224(e.g., {{GET}}, {{POST}}, {{PUT}}).  {{method}} can also be a list of
     225methods.  In this case, awful will define a page for each method of
     226the list.  Methods are case-insensitive.  Pages that use different
     227methods can use the same path.
    226228
    227229The {{css}}, {{title}}, {{doctype}}, {{headers}} and {{charset}}
  • release/4/awful/trunk/awful.scm

    r25348 r25369  
    442442  (when (debug-resources)
    443443    (debug-pp (hash-table->alist *resources*)))
    444   (or (hash-table-ref/default *resources* (list path vhost-root-path method) #f)
    445       (resource-match path vhost-root-path method)))
     444  (if (list? method)
     445      (let loop ((methods '(POST GET PUT DELETE HEAD)))
     446        (if (null? methods)
     447            #f
     448            (let ((method (car methods)))
     449              (or (hash-table-ref/default *resources*
     450                                          (list path vhost-root-path method)
     451                                          #f)
     452                  (resource-match path vhost-root-path method)
     453                  (loop (cdr methods))))))
     454      (or (hash-table-ref/default *resources* (list path vhost-root-path method) #f)
     455          (resource-match path vhost-root-path method))))
    446456
    447457(define (resource-match path vhost-root-path method)
     
    462472
    463473(define (add-resource! path vhost-root-path proc method)
    464   (hash-table-set! *resources* (list path vhost-root-path method) proc))
     474  (let ((methods (if (list? method) method (list method))))
     475    (for-each
     476     (lambda (method)
     477       (let ((upcase-method
     478              (string->symbol (string-upcase (symbol->string method)))))
     479         (hash-table-set! *resources* (list path vhost-root-path upcase-method) proc)))
     480     methods)))
    465481
    466482(define (reset-resources!)
Note: See TracChangeset for help on using the changeset viewer.