Can anyone show an example of doing a doing a redirect? I would like the browser to load a new url to be displayed in the 'Location:' field. I seem to remember being able to do this with other servers; perhaps I am using the wrong terminology. My guess is that I am supposed to have something in the response headers [of initial uri], but I cannot seem to get it right.
Also, this is kind of a CL question, but what do I need to do so that I can run the server in development debug mode? I don't want to print errors, I want to trap them and give me a debugger.
Thanks,
Andrew K. Wolven
P.S. It is both easy to implement and useful to have a prefix match with a user response function. I would like to suggest adding a publish-prefix or similar to the source.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here's an answer to the first of the three questions you asked.
It is an example of doing a redirect that I'll add to the examples file.
;; do a redirect to the picture
(publish :path "/pic-redirect"
:content-type "text/html"
:function
#'(lambda (req ent)
(with-http-response (req ent
:response *response-moved-permanently*)
(setf (reply-header-slot-value req "location") "/pic")
(with-http-body (req ent)
;; this is optional and most likely unnecessary since most
;; browsers understand the redirect response
(html
(:html
(:head (:title "Object Moved"))
(:body
(:h1 "Object Moved")
"The picture you're looking for is now at "
((:a :href "/pic") "This location"))))))))
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
second question: how do you debug response handlers.
The manual describes a function net.aserve::debug-on that can be be used to turn off the normal condition
handling, thus allowing error breaks to occur. This works best when using the emacs-lisp interface since
when error breaks occur in background processes a new emacs window is created in which to debug
that background process. One thing that we can't turn off (at this time) is the fact that there is a timeout for
the response function. Thus you only have a few minutes to debug the problem before the timeout kicks in and the response function aborts (you can always increase the timeout time).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The publish-directory function has all the code that's needed, we just need to split out the part that does prefix publishing into a separate function and then the directory publisher can use it as can a general prefix-based entities.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Can anyone show an example of doing a doing a redirect? I would like the browser to load a new url to be displayed in the 'Location:' field. I seem to remember being able to do this with other servers; perhaps I am using the wrong terminology. My guess is that I am supposed to have something in the response headers [of initial uri], but I cannot seem to get it right.
Also, this is kind of a CL question, but what do I need to do so that I can run the server in development debug mode? I don't want to print errors, I want to trap them and give me a debugger.
Thanks,
Andrew K. Wolven
P.S. It is both easy to implement and useful to have a prefix match with a user response function. I would like to suggest adding a publish-prefix or similar to the source.
Here's an answer to the first of the three questions you asked.
It is an example of doing a redirect that I'll add to the examples file.
;; do a redirect to the picture
(publish :path "/pic-redirect"
:content-type "text/html"
:function
#'(lambda (req ent)
(with-http-response (req ent
:response *response-moved-permanently*)
(setf (reply-header-slot-value req "location") "/pic")
(with-http-body (req ent)
;; this is optional and most likely unnecessary since most
;; browsers understand the redirect response
(html
(:html
(:head (:title "Object Moved"))
(:body
(:h1 "Object Moved")
"The picture you're looking for is now at "
((:a :href "/pic") "This location"))))))))
Thanks,
that's what I wanted to do.
AKW
second question: how do you debug response handlers.
The manual describes a function net.aserve::debug-on that can be be used to turn off the normal condition
handling, thus allowing error breaks to occur. This works best when using the emacs-lisp interface since
when error breaks occur in background processes a new emacs window is created in which to debug
that background process. One thing that we can't turn off (at this time) is the fact that there is a timeout for
the response function. Thus you only have a few minutes to debug the problem before the timeout kicks in and the response function aborts (you can always increase the timeout time).
question 3: add a publish-prefix function
this is a good idea. We already have the mechanism in place to handle this.
jfoderaro wrote:
> question 3: add a publish-prefix function
> this is a good idea. We already have the mechanism in place to
> handle this.
Is there a function for this yet?
--
chr
not yet.
The publish-directory function has all the code that's needed, we just need to split out the part that does prefix publishing into a separate function and then the directory publisher can use it as can a general prefix-based entities.