ring

James Amberger 2023-09-05T22:27:47.876849Z

I’m not sure I am taking full advantage of the repl when developing my ring app. If I modify a function in my editor and eval the definition, I then have to (future-cancel) the server and start a new one. What should I be doing?

seancorfield 2023-09-05T22:52:32.732929Z

Are you following the advice here? https://clojure.org/guides/repl/enhancing_your_repl_workflow#writing-repl-friendly-programs

seancorfield 2023-09-05T22:53:12.412569Z

Specifically, using #'handler instead of handler when starting your server and wrapping your handler with middleware. (hard to be more specific without seeing your code)

James Amberger 2023-09-05T23:35:44.055349Z

Yes, using #' seems to be what I’m missing. Thanks @seancorfield

Ben Sless 2023-09-06T05:07:25.524799Z

If you care about performance very much, another option is to eta expand the function:

(fn ([request] (handler request))
    ([request s f] (handler request s f)))

Ben Sless 2023-09-06T05:07:47.225079Z

You can call it a compiler trick

Ben Sless 2023-09-06T05:08:39.964519Z

But what I like doing in the repl is to not bring up a server, but have a function that returns my handler then call it and apply the handler to a request built with ring.mock

❤️ 1