cschneid / irclogger

Sinatra based irclogger.com
http://www.irclogger.com
147 stars 15 forks source link

It is impossible to fetch '/channels.json' #7

Open avsej opened 12 years ago

avsej commented 12 years ago

Hi @cschneid

It is impossible to reach "/channels.json" route because it falls into "/:channel". You should either check content type or move subject to the top

Thanks

cschneid commented 12 years ago

Thanks for the note - I plan on redoing a signifigant portion of the app. Were you wanting to actually use the API parts, or just noticing that?

Unless you're using it, I don't think anybody else is... might just remove it for now until somebody complains to get it back.

On Jan 12, 2012, at 4:16 AM, Sergey Avseyev wrote:

Hi @cschneid

It is impossible to reach "/channels.json" route because it falls into "/:channel". You should either check content type or move subject to the top

Thanks


Reply to this email directly or view it on GitHub: https://github.com/cschneid/irclogger/issues/7

avsej commented 12 years ago

I don't use channels.json but I use slice feature, could you also make sure your server sends the json in chunked mode. it would be killer feature. I'm going to use json logs as some kind of real world data for demo

cschneid commented 12 years ago

Cool, I'll not break it then :)

Chunked mode is interesting - since if you get a partial json doc, presumably it wouldn't parse.

Options I see: 1) Lots of individual json docs (probably accessed as several urls, not a single chunked transfer) 2) Streamable data format (xml [ugh], or csv or similar). 3) I misunderstood what you asked for with regards to json & chunked transfer

Any ideas / feedback? You're probably my only api consumer, so whatever you feel like is good with me.

On Jan 12, 2012, at 8:45 AM, Sergey Avseyev wrote:

I don't use channels.json but I use slice feature, could you also make sure your server sends the json in chunked mode. it would be killer feature. I'm going to use json logs as some kind of real world data for demo


Reply to this email directly or view it on GitHub: https://github.com/cschneid/irclogger/issues/7#issuecomment-3465179

avsej commented 12 years ago

It is possible to parse partial JSON (for example with my streaming parser experiment https://github.com/avsej/yaji

avsej commented 12 years ago

Or you can render several independent JSON objects. It will work too

cschneid commented 12 years ago

Interesting. Good to know about.

Do you have a preference on approach? I suppose just turning on chunked would be pretty transparent to old-style (all-at-once) consumers of the api, and then still enable your style.

The only gotcha is that there's not trivial way to generate a streaming json response in the server side. With the newest sinatra I could use the stream() thing, but the json library doesn't incrementally build json, so I'd end up doing that by hand.

What are you planning on using this all for? Is it a real use of the api, or am I just a handy data source online?

Anyway, I'll see what I can do in the next few days regarding something like chunked encoding.

On Jan 12, 2012, at 9:20 AM, Sergey Avseyev wrote:

It is possible to parse partial JSON (for example with my streaming parser experiment https://github.com/avsej/yaji


Reply to this email directly or view it on GitHub: https://github.com/cschneid/irclogger/issues/7#issuecomment-3465793

avsej commented 12 years ago

here you can find sample for streaming with yajl https://github.com/brianmario/yajl-ruby/blob/master/examples/encoding/chunked_encoding.rb but the API is simple enough to just render json manually or something like that

stream do |out|
  out << '['
  last = @messages.pop
  @messages.each do |message|
    out << message.to_json << ","
  end
  out << last << "]"
end

I'm planning to use it for handy datasource mainly.