duct-framework / duct

Server-side application framework for Clojure
MIT License
1.13k stars 51 forks source link

500 error on out of box config #68

Closed kenanwarren closed 5 years ago

kenanwarren commented 6 years ago

Hi, I was testing out duct and ran into a 500 error. The steps to reproduce were:

  1. lein new duct foo +api +ataraxy +cljs +example +site +heroku +postgres
  2. lein repl
  3. (dev)
  4. (go)
  5. Navigate to http://localhost:3000/example
  6. Hands back the following error: `Problem accessing /example. Reason:

    No implementation of method: :write-body-to-stream of protocol: #'ring.core.protocols/StreamableResponseBody found for class: clojure.lang.PersistentArrayMap`

Anything I might be missing in the setup?

weavejester commented 6 years ago

+api and +site aren't designed to be used together, so a problem occurs when the example handler tries to be both an API and site route. This issue might take a while to get fixed, but it will eventually be resolved.

In the meantime, I might add an error notice to the template that forbids +api and +site to be used together.

kenanwarren commented 6 years ago

Ah ok, thanks!

green-coder commented 6 years ago

I encountered this problem as well, and did not see any error message at project creation. Maybe you can add a note in the README.md in the meantime.

razum2um commented 5 years ago

@weavejester I see a lot changed in 0.7 branches, and there's not much sense in PR

but just FYI @Redorb if you're on 0.6 I got the actual default config for duct.core/handler and updated middleware stack like this and error went away

 :duct.core/handler {:middleware ^:replace [#ig/ref :duct.middleware.web/not-found
                                           ;; #ig/ref :duct.middleware.web/stacktrace ;; this caused bugs
                                           #ig/ref :duct.middleware.web/hide-errors
                                           #ig/ref :duct.middleware.web/format
                                           #ig/ref :duct.middleware.web/defaults
                                           #ig/ref :duct.middleware.web/log-requests
                                           #ig/ref :duct.middleware.web/log-errors
                                           ],
                    :router #ig/ref :duct.router/ataraxy}
weavejester commented 5 years ago

This is fixed in the Duct alpha release, so I'm closing it.