Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 25 17:33
    t-richards opened #84
  • Aug 13 11:21
    vladfaust closed #7
  • Aug 13 11:19
    vladfaust closed #108
  • Aug 13 11:19
    vladfaust closed #109
  • Aug 13 11:17
    vladfaust closed #24
  • Aug 09 08:46
    vladfaust review_requested #109
  • Aug 09 08:46
    vladfaust review_requested #7
  • Aug 08 20:13
    arubinofaux opened #7
  • Aug 08 20:13
    arubinofaux opened #109
  • Aug 02 11:31
    RemiKalbe edited #24
  • Aug 02 11:29
    RemiKalbe opened #24
  • Aug 01 12:52
    RemiKalbe edited #83
  • Aug 01 12:51
    RemiKalbe opened #83
  • Jul 30 18:36
    vladfaust closed #23
  • Jul 30 18:33
    vladfaust transferred #82
  • Jul 30 18:33
    RemiKalbe opened #23
  • Jul 30 15:55
    RemiKalbe opened #82
  • Jul 26 11:12
    repomaa synchronize #107
  • Jul 25 11:31
    repomaa synchronize #107
  • Jul 24 21:52
    repomaa opened #108
Vlad Faust
@vladfaust
Gonna update docs and blogposts and then release 0.4.0
Muhammed Yaşar
@yorci
Hi @vladfaust , do you have any nosql odm plan in the future?
Vlad Faust
@vladfaust
@yorci No, I don't think so. NoSQL has no standard and I see no point in supporting certain database drivers
Muhammed Yaşar
@yorci
i see
Lairan
@alex-lairan

NoSQL has no standard, but some subset have standard.

Key Store have (a kind of) standard for example.

Daniel Sokil
@s0kil
Since there are so many of NoSQL DB's, it would be ideal to provide easier integration with the DB of choice.
BlobCodes
@BlobCodes_gitlab
Hello, does anyone know how to use the StaticFileHandler with Onyx ?
Vlad Faust
@vladfaust

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.

BlobCodes
@BlobCodes_gitlab
Thanks!
Vlad Faust
@vladfaust
My pleasure :)
BlobCodes
@BlobCodes_gitlab

Hmm..
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" ?

BlobCodes
@BlobCodes_gitlab
I now resolved the segfault issue, but the "Not Found" is still there.. huh..
Vlad Faust
@vladfaust
I guess you have put the handler before router
‘pp handlers’ to see actual handlers and then insert your handler somewhere. Experiment with the best placement for it. You can do ‘handlers.insert(n, your_handler)’ for precision
BlobCodes
@BlobCodes_gitlab
Thanks!
Now everything works like a charm!
Marwan Rabbâa
@waghanza
@vladfaust in https://github.com/onyxframework/http/blob/master/src/onyx-http/middleware/renderer/rest_error.html.ecr we have ::HTTP::Status.new(500)
when trying to compile I have in lib/onyx-http/src/onyx-http/middleware/renderer/rest_error.html.ecr:4: undefined constant ::HTTP::Status
Vlad Faust
@vladfaust
@everyone recent dependency renaming led to colossal failures due to crystal-lang/shards#272. You should avoid using shards install for now.
@waghanza you should use Crystal 0.28.0 for that. Also, don't due to the message above :sweat_smile:
I'l try to fix the error using commits instead of tags later today
Marwan Rabbâa
@waghanza
Crystal 0.28.0 (2019-04-18)

LLVM: 6.0.1
Default target: x86_64-unknown-linux-gnu
Shards 0.9.0.rc1 (2019-02-09)
Vlad Faust
@vladfaust
@waghanza it builds on Travis and on my machine https://travis-ci.org/onyxframework/http
Marwan Rabbâa
@waghanza
@vladfaust :ok: compiling inside a container (docker) ;-), on my workstation I have the shards failure from above
Vlad Faust
@vladfaust
@everyone I've fixed the issue rolling back time_format.cr repository and creating new https://github.com/vladfaust/time-span-humanize. If you encounter any errors regarding to shards from now, you should delete shard.lock and also clean ~/.cache/shards/
Marwan Rabbâa
@waghanza
could someone review this PR => the-benchmarker/web-frameworks#1282, plz ?
Vlad Faust
@vladfaust
Why would you need a review, @waghanza? If it compiles, you did a good job then :)
Marwan Rabbâa
@waghanza
it just because of if there is a cleaner way to code this ;-)
like an advanced feat of onyx not used
Vlad Faust
@vladfaust
If I invent something outstanding, I would never forget to update the code in the bench!
Marwan Rabbâa
@waghanza
:+1:
Qinsi (James) ZHU
@qszhu
Hello, I’m writing an auth module according to this: https://github.com/vladfaust/crystalworld/blob/master/src/endpoints/auth.cr Instead of checking the header, it needs to check the request body. However, in the endpoint that includes this module a json macro is used, and it seems the context.request.body is already consumed by it before the before callback is called. Any ideas?
Vlad Faust
@vladfaust
Hey, @qszhu, thanks for the question! You could try rewinding the request body (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)
Qinsi (James) ZHU
@qszhu
rewind is unimplemented since the body I’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::Request like 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.
Vlad Faust
@vladfaust
@qszhu yes, body is always of fixed length. Copying the body on every request (i.e. monkey-patching the HTTP::Request class) 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
Qinsi (James) ZHU
@qszhu
Well, if I read it correctly, the body is only parsed if the content length is not zero. Thus, it’s only copied in those POST/PUT requests that you usually need to do json/form params parsing. The only difference is when there is a request body and you chose not to parse params from it. Am I right? Still, copying is not ideal. I used to implement this kind of stuff in a custom middleware plugged into specific routes (in Express.js/Koa.js). It seems there’s no easier way than mangling with the fixed middleware pipeline of onyx right now.
Vlad Faust
@vladfaust
Once the issue is closed, it would be easy
Qinsi (James) ZHU
@qszhu
Great! 👍 Is there anything I can help?
Vlad Faust
@vladfaust
That's quite advanced level, therefore I don't think so. I'll tackle it in days, as you currently have a workaround
Adrian Madrid
@aemadrid
is there a way to list the routes defined?
Qinsi (James) ZHU
@qszhu
@aemadrid try this: https://gist.github.com/qszhu/b31fa84f47a4c17581ff1dc21daa7049 .
It’s undocumented so I think it’s better not to rely on it.
Vlad Faust
@vladfaust
This would print static routes only, though
Vlad Faust
@vladfaust
BTW, @aemadrid why would you need that? Apart from onyxframework/onyx#15
Adrian Madrid
@aemadrid
just trying to debug something
but it is still a nice way to document/show people what your app can do
figured out my problem but it would have been nice to know
Dainel Vera
@arubinofaux_twitter
Hey @vladfaust quick question, i was just testing EDA with a redis url that contains a password. it resulted in this error
DEBUG [19:56:36.550 #1] [redis] CLIENT ID

Unhandled exception: NOAUTH Authentication required. (MiniRedis::Error)
  from ???
  from /usr/share/crystal/src/pointer.cr:434:13 in 'receive'
  from lib/mini_redis/src/mini_redis.cr:176:15 in 'send_impl'
  from lib/mini_redis/src/mini_redis.cr:89:5 in '???'
  from lib/onyx-http/src/onyx-http/ext/http/request/path_params.cr:1:1 in '__crystal_main'
  from /usr/share/crystal/src/crystal/main.cr:47:14 in 'main'
  from __libc_start_main
  from _start
  from ???
Vlad Faust
@vladfaust
Well, there is no specification in Redis for URI authentication, and mini_redis does not implement any custom wrapping as well
As a workaround, you could pass custom MiniRedis instance to Onyx::EDA: Onyx::EDA::Channel::Redis.new
Just call redis.send("AUTH", password) before, as seen at redis.io
You could create an issue @ mini_redis if you think this should be automated