You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by Pete Wyckoff <pw...@facebook.com> on 2008/09/15 20:03:44 UTC

-rest -java?

Are there any current plans for supporting the -rest flag in java?

Thanks, pete


-------------------------------------------------------------------

Mark Slee mslee at facebook.com
Mon Nov 19 17:22:25 PST 2007

    * Previous message: [Thrift] PHP Development
    * Next message: [Thrift] Re: Thrift + Apache
    * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

Hi Andrew,

This isn't the primary design case for Thrift, but you can use Thrift to
help structure this sort of code. Facebook uses Thrift in the
implementation of our REST web-services API.

General approach:

Define your types and web service in a .thrift file.
Generate PHP code using -rest flag.

Thrift generates a REST handler for your service implementation, which
you can invoke by passing the request variables. So you would have
something like:

$impl = new ServiceImplementation(); // your class that implement
methods
$rest = new ServiceRest($_REQUEST); // generated handler

Then you can invoke something like:

$method = $_REQUEST['method'];
$result = $rest->$method($request);

This will dispatch into your $impl class which can return a Thrift
object as $result.

We have common PHP functions that generically convert any Thrift object
into generic XML or JSON just by iterating over the elements.

So... it's not the primary use case, but Thrift is a nice way to
separate the data/types and method implementations from the
encoding/decoding details of input/output (i.e. GET params vs. JSON,
etc.)

Cheers,
Mark

-----Original Message-----
From: thrift-bounces at publists.facebook.com
[mailto:thrift-bounces at publists.facebook.com] On Behalf Of Andrew Eross
Sent: Sunday, November 18, 2007 6:42 PM
To: thrift at publists.facebook.com
Subject: [Thrift] PHP Development

Hi folks,

Simple question about thrift that I haven't quite been able to discern
from the available documentation...

We have a bunch of PHP class libraries that we would like to expose as
a number of different web services. The same libraries will be
implemented in a few different ways and accessible via REST/JSON and
REST/XML.

We're trying to decide if thrift may be helpful as an abstract way of
implementing these services to be accessible by PHP. We're about to
dive in a give it a go, but wanted to ask the community if this is
what thrift is intended for.

Cheers,
Andrew
_______________________________________________
Thrift mailing list
Thrift at publists.facebook.com
http://lists.pub.facebook.com/mailman/listinfo/thrift





Re: -rest -java?

Posted by Todd Lipcon <to...@amiestreet.com>.
On Mon, 15 Sep 2008, Pete Wyckoff wrote:

> We have common PHP functions that generically convert any Thrift object
> into generic XML or JSON just by iterating over the elements.

For what it's worth, those functions are publically available as part of 
the fbopen release. We've been using this as a basis for our JSON/XML/AMF 
API and it's working great so far.

-Todd

Re: -rest -java?

Posted by Mark Slee <mc...@facebook.com>.
Re: -rest -java?Sounds pretty useful to me. Want to open up a JIRA task to track this?
  ----- Original Message ----- 
  From: Amit Sudharshan 
  To: thrift-dev@incubator.apache.org 
  Sent: Monday, September 15, 2008 7:26 PM
  Subject: Re: -rest -java?


  We could generate standard HttpServlet classes which implement the service
  and ".war" them up for distribution in any servlet container (or just
  generate the .java files which can then be wrapped with a proper web.xml
  file)

  -Amit

  On Mon, Sep 15, 2008 at 4:10 PM, Mark Slee <ms...@facebook.com> wrote:

  > No specific plans that I'm aware of at the moment. But I don't think
  > there's any reason not to do this -- the need probably just hasn't come
  > up for anyone yet.
  >
  > How would you plan on doing this? Pulling the request arguments out of a
  > standard Servlet container?
  >
  > -----Original Message-----
  > From: Pete Wyckoff [mailto:pwyckoff@facebook.com]
  > Sent: Monday, September 15, 2008 11:04 AM
  > To: thrift-dev@incubator.apache.org
  > Subject: -rest -java?
  >
  >
  > Are there any current plans for supporting the -rest flag in java?
  >
  > Thanks, pete
  >
  >
  > -------------------------------------------------------------------
  >
  > Mark Slee mslee at facebook.com
  > Mon Nov 19 17:22:25 PST 2007
  >
  >    * Previous message: [Thrift] PHP Development
  >    * Next message: [Thrift] Re: Thrift + Apache
  >    * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
  >
  > Hi Andrew,
  >
  > This isn't the primary design case for Thrift, but you can use Thrift to
  > help structure this sort of code. Facebook uses Thrift in the
  > implementation of our REST web-services API.
  >
  > General approach:
  >
  > Define your types and web service in a .thrift file.
  > Generate PHP code using -rest flag.
  >
  > Thrift generates a REST handler for your service implementation, which
  > you can invoke by passing the request variables. So you would have
  > something like:
  >
  > $impl = new ServiceImplementation(); // your class that implement
  > methods $rest = new ServiceRest($_REQUEST); // generated handler
  >
  > Then you can invoke something like:
  >
  > $method = $_REQUEST['method'];
  > $result = $rest->$method($request);
  >
  > This will dispatch into your $impl class which can return a Thrift
  > object as $result.
  >
  > We have common PHP functions that generically convert any Thrift object
  > into generic XML or JSON just by iterating over the elements.
  >
  > So... it's not the primary use case, but Thrift is a nice way to
  > separate the data/types and method implementations from the
  > encoding/decoding details of input/output (i.e. GET params vs. JSON,
  > etc.)
  >
  > Cheers,
  > Mark
  >
  > -----Original Message-----
  > From: thrift-bounces at publists.facebook.com [mailto:thrift-bounces at
  > publists.facebook.com] On Behalf Of Andrew Eross
  > Sent: Sunday, November 18, 2007 6:42 PM
  > To: thrift at publists.facebook.com
  > Subject: [Thrift] PHP Development
  >
  > Hi folks,
  >
  > Simple question about thrift that I haven't quite been able to discern
  > from the available documentation...
  >
  > We have a bunch of PHP class libraries that we would like to expose as a
  > number of different web services. The same libraries will be implemented
  > in a few different ways and accessible via REST/JSON and REST/XML.
  >
  > We're trying to decide if thrift may be helpful as an abstract way of
  > implementing these services to be accessible by PHP. We're about to dive
  > in a give it a go, but wanted to ask the community if this is what
  > thrift is intended for.
  >
  > Cheers,
  > Andrew
  > _______________________________________________
  > Thrift mailing list
  > Thrift at publists.facebook.com
  > http://lists.pub.facebook.com/mailman/listinfo/thrift
  >
  >
  >
  >
  >


Re: -rest -java?

Posted by Amit Sudharshan <am...@onellama.com>.
We could generate standard HttpServlet classes which implement the service
and ".war" them up for distribution in any servlet container (or just
generate the .java files which can then be wrapped with a proper web.xml
file)

-Amit

On Mon, Sep 15, 2008 at 4:10 PM, Mark Slee <ms...@facebook.com> wrote:

> No specific plans that I'm aware of at the moment. But I don't think
> there's any reason not to do this -- the need probably just hasn't come
> up for anyone yet.
>
> How would you plan on doing this? Pulling the request arguments out of a
> standard Servlet container?
>
> -----Original Message-----
> From: Pete Wyckoff [mailto:pwyckoff@facebook.com]
> Sent: Monday, September 15, 2008 11:04 AM
> To: thrift-dev@incubator.apache.org
> Subject: -rest -java?
>
>
> Are there any current plans for supporting the -rest flag in java?
>
> Thanks, pete
>
>
> -------------------------------------------------------------------
>
> Mark Slee mslee at facebook.com
> Mon Nov 19 17:22:25 PST 2007
>
>    * Previous message: [Thrift] PHP Development
>    * Next message: [Thrift] Re: Thrift + Apache
>    * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
>
> Hi Andrew,
>
> This isn't the primary design case for Thrift, but you can use Thrift to
> help structure this sort of code. Facebook uses Thrift in the
> implementation of our REST web-services API.
>
> General approach:
>
> Define your types and web service in a .thrift file.
> Generate PHP code using -rest flag.
>
> Thrift generates a REST handler for your service implementation, which
> you can invoke by passing the request variables. So you would have
> something like:
>
> $impl = new ServiceImplementation(); // your class that implement
> methods $rest = new ServiceRest($_REQUEST); // generated handler
>
> Then you can invoke something like:
>
> $method = $_REQUEST['method'];
> $result = $rest->$method($request);
>
> This will dispatch into your $impl class which can return a Thrift
> object as $result.
>
> We have common PHP functions that generically convert any Thrift object
> into generic XML or JSON just by iterating over the elements.
>
> So... it's not the primary use case, but Thrift is a nice way to
> separate the data/types and method implementations from the
> encoding/decoding details of input/output (i.e. GET params vs. JSON,
> etc.)
>
> Cheers,
> Mark
>
> -----Original Message-----
> From: thrift-bounces at publists.facebook.com [mailto:thrift-bounces at
> publists.facebook.com] On Behalf Of Andrew Eross
> Sent: Sunday, November 18, 2007 6:42 PM
> To: thrift at publists.facebook.com
> Subject: [Thrift] PHP Development
>
> Hi folks,
>
> Simple question about thrift that I haven't quite been able to discern
> from the available documentation...
>
> We have a bunch of PHP class libraries that we would like to expose as a
> number of different web services. The same libraries will be implemented
> in a few different ways and accessible via REST/JSON and REST/XML.
>
> We're trying to decide if thrift may be helpful as an abstract way of
> implementing these services to be accessible by PHP. We're about to dive
> in a give it a go, but wanted to ask the community if this is what
> thrift is intended for.
>
> Cheers,
> Andrew
> _______________________________________________
> Thrift mailing list
> Thrift at publists.facebook.com
> http://lists.pub.facebook.com/mailman/listinfo/thrift
>
>
>
>
>

RE: -rest -java?

Posted by Mark Slee <ms...@facebook.com>.
No specific plans that I'm aware of at the moment. But I don't think
there's any reason not to do this -- the need probably just hasn't come
up for anyone yet.

How would you plan on doing this? Pulling the request arguments out of a
standard Servlet container?

-----Original Message-----
From: Pete Wyckoff [mailto:pwyckoff@facebook.com] 
Sent: Monday, September 15, 2008 11:04 AM
To: thrift-dev@incubator.apache.org
Subject: -rest -java?


Are there any current plans for supporting the -rest flag in java?

Thanks, pete


-------------------------------------------------------------------

Mark Slee mslee at facebook.com
Mon Nov 19 17:22:25 PST 2007

    * Previous message: [Thrift] PHP Development
    * Next message: [Thrift] Re: Thrift + Apache
    * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

Hi Andrew,

This isn't the primary design case for Thrift, but you can use Thrift to
help structure this sort of code. Facebook uses Thrift in the
implementation of our REST web-services API.

General approach:

Define your types and web service in a .thrift file.
Generate PHP code using -rest flag.

Thrift generates a REST handler for your service implementation, which
you can invoke by passing the request variables. So you would have
something like:

$impl = new ServiceImplementation(); // your class that implement
methods $rest = new ServiceRest($_REQUEST); // generated handler

Then you can invoke something like:

$method = $_REQUEST['method'];
$result = $rest->$method($request);

This will dispatch into your $impl class which can return a Thrift
object as $result.

We have common PHP functions that generically convert any Thrift object
into generic XML or JSON just by iterating over the elements.

So... it's not the primary use case, but Thrift is a nice way to
separate the data/types and method implementations from the
encoding/decoding details of input/output (i.e. GET params vs. JSON,
etc.)

Cheers,
Mark

-----Original Message-----
From: thrift-bounces at publists.facebook.com [mailto:thrift-bounces at
publists.facebook.com] On Behalf Of Andrew Eross
Sent: Sunday, November 18, 2007 6:42 PM
To: thrift at publists.facebook.com
Subject: [Thrift] PHP Development

Hi folks,

Simple question about thrift that I haven't quite been able to discern
from the available documentation...

We have a bunch of PHP class libraries that we would like to expose as a
number of different web services. The same libraries will be implemented
in a few different ways and accessible via REST/JSON and REST/XML.

We're trying to decide if thrift may be helpful as an abstract way of
implementing these services to be accessible by PHP. We're about to dive
in a give it a go, but wanted to ask the community if this is what
thrift is intended for.

Cheers,
Andrew
_______________________________________________
Thrift mailing list
Thrift at publists.facebook.com
http://lists.pub.facebook.com/mailman/listinfo/thrift