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
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
Dainel Vera
@arubinofaux_twitter
@vladfaust thanks for the reply, it makes a lot more sense to me now
Qinsi (James) ZHU
@qszhu
Is there a way to use aggregate functions with the SQL builder? Currently I’m using the raw SQL like Onyx::SQL.scalar(“select avg(score) from scores where …”).
Vlad Faust
@vladfaust
That's the perfect way. Query builder is designed to be minimal, with very common things only
Qinsi (James) ZHU
@qszhu
I see. Thanks!
Vlad Faust
@vladfaust
Also, you could do that: Onyx::SQL.scalar(User.where(a: b).select("avg(score)"))
As most of query builder methods support raw SQL
Qinsi (James) ZHU
@qszhu
Nice! Wasn't aware of that
Vlad Faust
@vladfaust
The real reason for Query builder existence is that I didn't want to type full table names in SQL queries =) And also converting SQL rows to Crystal. That's minimal
I never intended to replace SQL. You should know raw SQL to make it work better, anyway
Qinsi (James) ZHU
@qszhu
Just enough to solve my problem👍
Vlad Faust
@vladfaust
That's another Onyx's motto =)
Qinsi (James) ZHU
@qszhu

I’m trying to return all the fields of a reference with join according to the doc: https://docs.onyxframework.org/sql/query.html#join Say I want to get all the fields of author. Do I have to write raw sql like

  .join(author: true) do |x|
    x.select(“author.*”)
  end

or is there any other way?

Vlad Faust
@vladfaust
Onyx::SQL is broken on 0.29.0. See onyxframework/sql#106. Any help would be appreciated
Vlad Faust
@vladfaust
Everything's fine, gonna update to 0.29.0 tomorrow :tada:

Hey @qszhu, sorry for the late response. You can do this:

.join(author: true, &.select(User))

This would effectively select all the fields of the author with proper table naming author. instead of users.