Onyx::SQL got a sweet new 0.7.2 release as well.
Onyx::HTTP is patched too.
I'm looking forward for the next Onyx release (0.4.0), which would include new API, testing helpers and new EDA version support
Yes, that docs section is still TODO.
Onyx::HTTP.listen method has a block to yield (https://github.com/onyxframework/onyx/blob/master/src/onyx/http.cr#L69). You have access to
handlers within the block:
Onyx::HTTP.listen do pp handlers end
Handlers is an array, you can modify it as you want, adding or removing custom handlers if needed.
When I try to do this:
spawn do Onyx::HTTP.listen do handlers.push(HTTP::StaticFileHandler.new("./public",false,false)) end end
..the StaticFileHandler makes every page show up as text.
Looks like this:
[some style stuff, etc.] <body> <div class="code">404</div> <h1 class="status-message">Not Found</h1> <div class="request-id">Request ID: a53ba92e-3a81-4abf-8252-fb228f560f5e</div> </body> </html> Not Found
(only works in release mode, segfaults in non-release mode)
What can I do so the StaticFileHandler doesn't append that "Not Found" ?
in lib/onyx-http/src/onyx-http/middleware/renderer/rest_error.html.ecr:4: undefined constant ::HTTP::Status
shards installfor now.
time_format.crrepository and creating new https://github.com/vladfaust/time-span-humanize. If you encounter any errors regarding to shards from now, you should delete
shard.lockand also clean
jsonmacro is used, and it seems the
context.request.bodyis already consumed by it before the
beforecallback is called. Any ideas?
context.request.body.rewind), but I'm not sure if it would work 🤔. For some reason in current release there is no way to preserve the body... Another workaround is to copy the body in a handler (i.e. custom middleware)
rewindis unimplemented since the
bodyI’m getting is a
FixedLengthContent < IO::Sized: https://github.com/crystal-lang/crystal/blob/b42631e9b3c62621f42832755427d530c6e452d2/src/http/common.cr#L37 I tried to patch
HTTP::Requestlike this: qszhu/http@d15c225 It works, but it feels awkward (and possibly with additional memory impact?). I’m still new to crystal, so any suggestion is welcome.
HTTP::Requestclass) would indeed affect the performance. That's why I've opened onyxframework/http#77. Note that the body is read on json and form params parsing only, and it should stay unread in an endpoint if no such a parsing happened