Improve the content negotiation handling in general
Previously, the routing layer handled the content negotiation, and the Accept header was ignored. Now, the extension if one is provided in the URL is still used, and more widely than before, but the Accept header is also taken in to account. This all now happens before the routing decisions are made, so the routing is now pretty much extension independant (with the exception of the /gnu/store/... routes).
This commit is contained in:
parent
640fb8a2ad
commit
658a1a20b2
3 changed files with 163 additions and 144 deletions
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
(define-module (guix-data-service web server)
|
||||
#:use-module (srfi srfi-1)
|
||||
#:use-module (srfi srfi-11)
|
||||
#:use-module (web http)
|
||||
#:use-module (web request)
|
||||
#:use-module (web uri)
|
||||
|
|
@ -30,9 +31,14 @@
|
|||
(define (run-controller controller request body)
|
||||
(with-postgresql-connection
|
||||
(lambda (conn)
|
||||
((controller request body conn)
|
||||
(cons (request-method request)
|
||||
(request-path-components request))))))
|
||||
(let-values (((request-components mime-types)
|
||||
(request->path-components-and-mime-type request)))
|
||||
(controller request
|
||||
(cons (request-method request)
|
||||
request-components)
|
||||
mime-types
|
||||
body
|
||||
conn)))))
|
||||
|
||||
(define (handler request body controller)
|
||||
(format #t "~a ~a\n"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue