<FromGitter>
<Blacksmoke16> i mean how else would you do it? In kemal land there isnt an abstraction around the response, so if the user does like `ctx.response << "foo"` the client has already been sent that data
<FromGitter>
<3n-k1> that could totally work
<FromGitter>
<3n-k1> well django has middleware hooks for when certain parts of the response throw an exception
<FromGitter>
<3n-k1> that's how i was thinking about it
<FromGitter>
<Blacksmoke16> as does Athena 😉
<FromGitter>
<3n-k1> athena does things in a way i don't like and i refuse to change, even if those changes are better!
<FromGitter>
<3n-k1> :p
<FromGitter>
<Blacksmoke16> hehe, it also maps exceptions to http errors, like you suggested in your issue
<FromGitter>
<3n-k1> oh no, i actaully really like athena
<FromGitter>
<3n-k1> nooo time to rewrite this entire application lol
<FromGitter>
<Blacksmoke16> boo :P maybe it would get simpler ha
<FromGitter>
<3n-k1> yeah. i'm not too far in, i think rewriting is for the best
<FromGitter>
<Blacksmoke16> but yea, kemal doesnt have some of those abstractions. And given the current state of it i wouldnt get my hopes too high
<FromGitter>
<3n-k1> spent most of the day planning out a forms/validation system, but i think athena would be a lot less work lol
<FromGitter>
<Blacksmoke16> doing server rendered HTML i assume? or REST?
<FromGitter>
<3n-k1> literally just browsing your routing docs and this looks exactly like what i want
<FromGitter>
<3n-k1> most likely a static frontend to a crud db with authentication
<FromGitter>
<3n-k1> for now, at least
<FromGitter>
<3n-k1> i mean, my routes are literally just returning static heredocs lol
<FromGitter>
<Blacksmoke16> ❤️ good to hear ha
<FromGitter>
<Blacksmoke16> could prob use like nginx or something if its just static no?
<FromGitter>
<3n-k1> does athena have something like django's `reverse` function, where you give it a name and it returns a url?
<FromGitter>
<3n-k1> i could but i have no idea how to use nginx
<FromGitter>
<3n-k1> and it's technically only *mostly* static
<FromGitter>
<Blacksmoke16> fair enough, would be more performant tho
<FromGitter>
<Blacksmoke16> yea fair enough
<FromGitter>
<Blacksmoke16> and not atm, but some work that im thinking thru now would allow for that i think
Elouin has quit [Read error: Connection reset by peer]
<FromGitter>
<Blacksmoke16> i assume thats for like generating links in the html?
Elouin has joined #crystal-lang
<raz>
pro-tip: nginx is for old people. caddy is where it's at.
<FromGitter>
<incognitorobito> ^
<FromGitter>
<Blacksmoke16> so iv'e heard :p
<oprypin>
caddy is for college students then or what
<FromGitter>
<incognitorobito> :p maybe
<FromGitter>
<Blacksmoke16> then what about apache :p
<FromGitter>
<3n-k1> apache is all i know and my god do i hate it
<FromGitter>
<3n-k1> when you thought xml was too simple so you extend it and make it worse
<FromGitter>
<3n-k1> > i assume thats for like generating links in the html? ⏎ whoops i missed your response, sorry! it's mostly for generating html, but also for redirecting to other urls. it's mainly used for reusable apps, but i really like the ability to change my entire url schema just by changing one thing in the urlconf
<FromGitter>
<3n-k1> that's why i was asking about macro hashmaps yesterday lol
<FromGitter>
<Blacksmoke16> based on what i read my understanding is if you have a route like `/user/:id` thats in a `UserController` you can do like `reverse('UserController:get_user', args: {"id" => 10})` and it return `/user/10` yea?
<FromGitter>
<Blacksmoke16> yea, think im trying to figure out now would enable that
<FromGitter>
<Blacksmoke16> thing*
<FromGitter>
<ImAHopelessDev_gitlab> just use php, duh /s
<FromGitter>
<3n-k1> @Blacksmoke16 yeah, something like that. in django, you define `path('user<pk>/', user_view, name='user_view')` and then you can call `reverse('user_view', pk=10)` and get back `/user/10`
<FromGitter>
<Blacksmoke16> 👍 perfect
<FromGitter>
<3n-k1> so yes, literally exactly what you wrote lol. django uses some centralized url configuration variables though, i'm not sure if you'd be able to get that with a macro?
<FromGitter>
<Blacksmoke16> plan atm is to abstract some logic into a new `Router` singleton type that knows about all the routes and stuff
<FromGitter>
<3n-k1> awesome! let me know if you need any help/extra info :)
<FromGitter>
<Blacksmoke16> will do
<FromGitter>
<Blacksmoke16> any other ideas/suggestions, or any questions etc you have feel free to join the Athena gitter ch
<FromGitter>
<3n-k1> what's the gitter? i can't find it lol
<FromGitter>
<3n-k1> is there a non-blocking `#receive` for Channel?
<FromGitter>
<3n-k1> i have discovered the select statement
Elouin has left #crystal-lang ["So long and thanks for all the fish!"]
<FromGitter>
<3n-k1> i've got this code, but it keeps crashing because it runs out of file descriptors. the Dir is never getting closed, and it looks like it isn't even getting garbage collected? ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ to the file, and the destructor never gets called. things work if i use a temp variable for `Dir.new`, but not without it' [https://gitter.im/crystal-lang/crystal?at=5fb4c3112a60f731f760d511]
<FromGitter>
<3n-k1> is that a bug, or did i just do a bad?
<FromGitter>
<3n-k1> if i use the `Dir.each_child` class method it also works fine
<FromGitter>
<HertzDevil> use `Dir.open` instead
<FromGitter>
<HertzDevil> that's what `.each_child` does too:
<FromGitter>
<ImAHopelessDev_gitlab> i don't think i've seen & : Type before
<FromGitter>
<naqvis> hi Girng
<FromGitter>
<naqvis> `&` is block argument and `->` is syntactic sugar for `Proc`
<FromGitter>
<naqvis> you can combine both together, assume you have a `Proc` and you want to pass that to a method, which is expecting block, then you can do `&->......`
<FromGitter>
<ImAHopelessDev_gitlab> oh i see, never used Procs before. Ty
<FromGitter>
<anthonyshull> i am very new to crystal and have have some questions about how to structure a program
<FromGitter>
<anthonyshull> i'm wanting to have a client that takes configuration and injects that into a service provider
<FromGitter>
<anthonyshull> are modules the best way to go?
<FromGitter>
<Blacksmoke16> sounds like a struct to store the config and a class method `self.from_config` that configures the provider with the config?
<FromGitter>
<Blacksmoke16> some example code would help here
<FromGitter>
<anthonyshull> also, they have a require at the bottom of the file, is that normal? i'm guessing so they have access to the Strip.client in other files
<FromGitter>
<tenebrousedge> it's not normal
<FromGitter>
<tenebrousedge> but maybe something else is overriding that class later?
<FromGitter>
<Blacksmoke16> i mean you could have class methods on the classes that new up a client and do the request and return the data
<FromGitter>
<Blacksmoke16> `HTTP::Client` does something similar
<FromGitter>
<Blacksmoke16> but id maybe keep things simple for now and can always iterate
<FromGitter>
<Blacksmoke16> build a good foundation then go from there
<FromGitter>
<tenebrousedge> that lib doesn't have a version file
<FromGitter>
<tenebrousedge> so I suppose it's declaring the class there so that they can use the short syntax without Crystal thinking that `Stripe` is a module
<FromGitter>
<tenebrousedge> I don't think I get the class variables
<FromGitter>
<tenebrousedge> but w/e
<FromGitter>
<Blacksmoke16> prob are assuming they keys are the same globally
chloekek has joined #crystal-lang
Human_G33k has quit [Remote host closed the connection]
<erdnaxeli>
Hi, this gitter channel used to be bridged with a room on Matrix. But the bot (on gitter side) responsible for the bridging was banned on the 1st of january 2018, hence breaking the bridge. Should it be possible to maybe unban the bot (it's matrixbot), in order to restore the bridge? Or was there a good reason to ban it?
<erdnaxeli>
currently I am also talking from matrix, but from the room bridged to the freenode channel, itself bridged to gitter
<FromGitter>
<anthonyshull> is there a recommended HTTP client library that does things like base_uri, headers, and retries?
<FromGitter>
<Blacksmoke16> stdlib can do most of that
<FromGitter>
<Blacksmoke16> minus the retry part, but should be easy enough to handle id think
<FromGitter>
<watzon> @anthonyshull it's recommended to use the stdlib HTTP client if possible. If you really need the extra features there's Halite and Crest, but they come at a major speed decrease.
Human_G33k has joined #crystal-lang
<FromGitter>
<watzon> I use to use Halite for my Tourmaline library until I learned that it was the reason my latency was so bad
<FromGitter>
<anthonyshull> this is just for demo so speed isn't a problem
<FromGitter>
<Blacksmoke16> also consider its another dependency
<FromGitter>
<Blacksmoke16> that could change/break etc
<FromGitter>
<Blacksmoke16> there is an issue about revamping the http client in the stdlib to support more stuff, but id imagine thats an after 1.0 thing
<FromGitter>
<watzon> Which happens plenty
<FromGitter>
<anthonyshull> yeah, i'll probably just use HTTP::Client
<FromGitter>
<watzon> Speaking of 1.0, is that ever gonna happen? Here I was thinking 3 months ago that it would be right around the corner, yet here we are still on 0.35.1
<FromGitter>
<Blacksmoke16> or if anything make your client type wrap it
<FromGitter>
<Blacksmoke16> @watzon theres a PR for first prerelease
<FromGitter>
<watzon> Woop woop
<FromGitter>
<watzon> Can't come soon enough
<FromGitter>
<tenebrousedge> @watzon o/
<FromGitter>
<watzon> What's up O/
<FromGitter>
<tenebrousedge> not a lot. Took a break from coding in order to learn makeup and stuff. Starting to pick that up again
<FromGitter>
<watzon> Fun fun haha. I'm actually dealing with some marketing shit right now myself.
<FromGitter>
<watzon> Trying to finesse the HubSpot API to do what we need
<FromGitter>
<Blacksmoke16> :thinking: i think you should reread what he said @watzon 😆
<FromGitter>
<anthonyshull> if i do `module Foo::Bar` is that the same as nesting a Bar module in a Foo module?
<FromGitter>
<Blacksmoke16> yes
<FromGitter>
<anthonyshull> noice
<FromGitter>
<Blacksmoke16> can also do like `class Foo::Bar::MyClass`
<FromGitter>
<anthonyshull> yeah, i saw that too. perfect.
<FromGitter>
<watzon> LMAO
<FromGitter>
<watzon> Man I'm tired
<FromGitter>
<watzon> Time to go back to bed
<FromGitter>
<erdnaxeli_gitlab> > *<erdnaxeli>* Hi, this gitter channel used to be bridged with a room on Matrix. But the bot (on gitter side) responsible for the bridging was banned on the 1st of january 2018, hence breaking the bridge. Should it be possible to maybe unban the bot (it's matrixbot), in order to restore the bridge? Or was there a good reason to ban it? ⏎ ⏎ Hi, I'm the same guy. Who are the admins there?
<FromGitter>
<watzon> Makeup is cool too lol
<FromGitter>
<tenebrousedge> @Blacksmoke16 pronouns are she / her these days
<FromGitter>
<watzon> @erdnaxeli_gitlab I think @oprypin is in charge of the IRC bridge. Might be a good place to start.
<FromGitter>
<erdnaxeli_gitlab> thanks
<oprypin>
i'm not aware of any ban but i am opposed to such a bot
<oprypin>
erdnaxeli, can't Matrix just use IRC?
<FromGitter>
<erdnaxeli_gitlab> it can but why couldn't it use a bridge with a better integration?
<FromGitter>
<erdnaxeli_gitlab> my problem is that relay bots looks ugly, and it could be way better on matrix side with a proper bridge. But indeed on the gitter side it would be another relay bot. A solution could be to do IRC <-> Matrix (this bridge does not use relay bot but actually connects users) and then Matrix <-> gitter
<erdnaxeli>
here I am talking from Matrix but you don't see any relay bot on IRC
<oprypin>
there is a bot bridging 2 channels. you cannot add another bot that's aware only of one side, you have to be responsible for a 3-way implementation
<erdnaxeli>
anyway as Element (the guy behind matrix) bought Gitter a proper bridge (without relay bot on gitter side) is coming
<oprypin>
erdnaxeli, > here I am talking from Matrix but you don't see any relay bot on IRC - well yes, why not just do that?
<erdnaxeli>
because for users talking on gitter I see the relay bot as you do en IRC
<FromGitter>
<tenebrousedge> s/module/class as need be
<hightower2>
Hey for a list of strings, I need to check whether they are "allowed". What's the best structure for this? Do I keep calling e.g. `if list.includes?(word)`, or use a Hash and check with h[word]?, or even use a Set?
<hightower2>
Or even a tuple/named tuple? The list of allowed words has about 10 fixed/static entries.
<FromGitter>
<tenebrousedge> I would do `entries - ["abc", "bcd"]`
<hightower2>
You wouldn't care about this creating an object as aside effect?
<FromGitter>
<tenebrousedge> not unless `entries` was large
<hightower2>
ok, nice idea, thanks. (Still if someone has a recommendation for one of the 5 data structures mentioned above, it would be appreciated, just for info if nothing else)
<oprypin>
hightower2, if u create the set of words once, create it as a `Set`
<FromGitter>
<tenebrousedge> if you want the allowed stuff in `entries` you could do `allowed_entries = entries & allowed`
<FromGitter>
<tenebrousedge> and yes `Set` is best
<hightower2>
++
<FromGitter>
<tenebrousedge> `Set` and `Array` both have `&` and `-`
<FromGitter>
<tenebrousedge> `Set` also has `superset?`
<FromGitter>
<tenebrousedge> and `subset?`
<oprypin>
those have no chance of outperforming `.all .includes`
<FromGitter>
<anthonyshull> what does ::One::Two mean?
<FromGitter>
<anthonyshull> or is that just a ruby thing?
<oprypin>
means `One::Two` but doesn't allow `Submodule::One::Two` if you're in `Submodule`
<FromGitter>
<anthonyshull> ah, cool, thanks
hightower3 has joined #crystal-lang
hightower2 has quit [Ping timeout: 240 seconds]
<hightower3>
As a side question, if I want to count on crystal to raise an exception if a key is missing, such as `["a", "b", "c"].each { |x| hash[x] }` will this work fine or possibly be optimized away ?
<oprypin>
seems ok
<FromGitter>
<tenebrousedge> I might use `all?` instead of `each` there, depending on exactly what you're after
Human_G33k has quit [Remote host closed the connection]
<hightower3>
Hm, since the params are coming from HTTP::Params, the code I have is now: `allowed_params = Set{"one", "two"}; invalid_params = context.request.query_params.to_h.keys.to_set - allowed_params`. Not very elegant. Any hints there?
Human_G33k has joined #crystal-lang
<FromGitter>
<tenebrousedge> use `query_params.reject(&->allowed.includes?(String))`
<FromGitter>
<tenebrousedge> or something similar
<FromGitter>
<Blacksmoke16> is this so you can return an error to the client or something?
<hightower3>
Blacksmoke16: right, the API which I need to replicate does this, so I need to too.
<FromGitter>
<Blacksmoke16> gotcha
<FromGitter>
<3n-k1> is there a way to construct a method call from a macro?
<FromGitter>
<Blacksmoke16> prob yea, got some sample code?
<FromGitter>
<3n-k1> like, i have the class name, and i have the method name. i tried `#{{{var.id}}.{{var.type.class.methods[1].name}}()}` but that just doesn't work
<FromGitter>
<Blacksmoke16> where to the args to it come from?
<FromGitter>
<anthonyshull> from the wrapping class
<FromGitter>
<Blacksmoke16> you can do like `class_getter address : ShipEngine::Service::Address { ShipEngine::Services::Address.new .. }`
<FromGitter>
<Blacksmoke16> which would only instantiate it when its called
<FromGitter>
<Blacksmoke16> and essentially act as a singleton
<FromGitter>
<anthonyshull> hum, i'll give that a try
<FromGitter>
<Blacksmoke16> if its ok that multiple invocations of it can share the same obj ofc
ua_ has quit [Ping timeout: 256 seconds]
ua_ has joined #crystal-lang
<FromGitter>
<j8r> @Blacksmoke16 @oprypin worse is `./dir/**`
<FromGitter>
<j8r> if you know you need everything on a directory, it `/*` is fine.
<FromGitter>
<Simerax> Ive seen that 1.0 is in the making or at least Pull 9892 Release 1.0.0-pre1 (https://github.com/crystal-lang/crystal/pull/9892). There are a few things related to windows . Will this mean 1.0 will ship with windows support or is it more like one step closer to windows support?
<FromGitter>
<Blacksmoke16> Windows support isn't a goal of 1.0
<FromGitter>
<Blacksmoke16> Though it does include some things to get a bit closer iirc
<FromGitter>
<3n-k1> is the windows-support meta issue still current?
<FromGitter>
<Blacksmoke16> Yes
<FromGitter>
<3n-k1> ~~refusing to support windows to try and force people into the *nix land~~
<FromGitter>
<Simerax> thanks for the info. i guess ill check out the "meta issue" then :D