rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
From: Daniel N <has.sox@gmail.com>
To: rack-devel@googlegroups.com
Subject: Re: Rack as a client-side spec
Date: Tue, 5 May 2009 16:48:11 +1000	[thread overview]
Message-ID: <2fff50390905042348i2b340cbcrbeeabc94c587da43@mail.gmail.com> (raw)
In-Reply-To: <E34D5596-373A-4DBB-AE89-EC22B7C8F383@spork.in>

[-- Attachment #1: Type: text/plain, Size: 1472 bytes --]

On Tue, May 5, 2009 at 2:16 PM, Tim Carey-Smith <g@spork.in> wrote:

>
> Hey there,
>
> I've been dealing with the painful API that is Net::HTTP and RestClient.
>
> It seems to me that it would make sense for there to be a client lib which
> accepted a Rack environment and made a real HTTP request on the wire.
> This would return the Rack response: [status, headers, body] and allow
> people to build tools which worked against a real web-service as well as a
> Rack app.
>
> I've got an implementation for doing this using Mechanize as the backend,
> but it feels to weighty.
> As I would see it, the library would allow the following:
>
>  res = Rack::MockRequest.new(RackClient::HTTP.new).get("/foo", "HTTP_HOST"
>> => "example.org")
>>
>
> Which would result in 'res' containing the data at http://example.org/foo
>
> Does this sound like a good idea? It means we can leverage the power of
> middleware on the client-side too.
>
>  app = Rack::Builder.app do
>>  # For http auth
>>  use RackClient::Auth::Basic, "username", "password"
>>  # For json serialization
>>  use RackClient::JSON
>>  run RackClient::HTTP
>> end
>>
>
> This could probably be wrapped in a nicer API, but I think that shows the
> general idea.
>
> Please tell me I'm missing something insanely stupid and this has been
> thought of and rejected before.
> (Or not...)
>
> Ciao,
> Tim


I really like this idea.  I can think of a couple of things I'd like to use
it for already.

Cheers
Daniel

[-- Attachment #2: Type: text/html, Size: 2329 bytes --]

  reply	other threads:[~2009-05-05  6:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-05  4:16 Rack as a client-side spec Tim Carey-Smith
2009-05-05  6:48 ` Daniel N [this message]
2009-05-10 11:35 ` Christian Neukirchen
2009-05-10 14:10   ` Joshua Peek
2009-05-10 22:54     ` Daniel N
2009-07-01 18:00       ` Bill Burcham
2009-07-02 16:11         ` Simon Rozet
2009-07-02 19:41           ` Bill Burcham

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://groups.google.com/group/rack-devel

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2fff50390905042348i2b340cbcrbeeabc94c587da43@mail.gmail.com \
    --to=rack-devel@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).