fukamachi / ningle

Super micro framework for Common Lisp
http://8arrow.org/ningle/
273 stars 25 forks source link

Redirect function #40

Open jgarte opened 2 years ago

jgarte commented 2 years ago

Hi @fukamachi, should ningle have a redirect function built in like sinatra does?

This code or similar seems like it should be part of ningle:

(defun redirect (url &optional (status 302))
           (setf (getf (lack.response:response-headers ningle:*response*) :location) url)
           (setf (lack.response:response-status ningle:*response*) status))

Alex had shared the above with me.

Ed shared the following approach:

(setf (ningle:route app "/path") (lambda (params) '(list 302 (:location "https://google.com") ())))

or the following in a REPL:

https://fwoar.co/pastebin/bb324cec458c9b966c6fb15ed08018a5c63ef04a.lisp.html

I realize that caveman has a redirect function but I think ningle should maybe have one also.

WDYT?