pandeiro / boot-http

A simple HTTP serve task for the Boot build tool
62 stars 34 forks source link

Allow :not-found to access options passed to server #67

Open kennyjwilli opened 7 years ago

kennyjwilli commented 7 years ago

Right now the :not-found option expects a symbol that points to a Ring handler. This won't work if my response depends on some options set when starting the server. I would like to either (1) change this option to take in the server options and return a Ring handler or (2) add a new option that takes the server options and returns a Ring handler.

Option (1) will be a breaking change and option (2) would not. I have some preliminary code written that will solve this issue. However, the name for this option is not yet determined due to the aforementioned reasons.

pandeiro commented 7 years ago

Trying to better understand the use case for this, but answer me this:

Why can't your invocation of the serve task and your not-found handler obtain those options from the same place, such as a configuration file?

kennyjwilli commented 7 years ago

I actually got my specific use case to work with just the :not-found option. My end goal in this issue was to create a general function that would always return the same resource response for any route. I believe this would be a useful addition to the library. The cleanest way to do this would be through a function that takes the server options and returns the not found handler. As you mentioned, you could have the caller pass in the arguments explicitly, however, this is repeated information that could be easily be handled automatically.

Unless another use-case for this comes up requiring a general solution, I suggest we close this issue.