用于AppEngine的RESTFul服务框架 [英] RESTFul Service Framework for AppEngine

查看:147
本文介绍了用于AppEngine的RESTFul服务框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个涉及Google AppEngine PAAS的移动和网络客户端的项目。我希望在我的AppEngine应用程序中使用RESTFul web服务。我已经浏览了Stackoverflow,以了解可以与AppEngine一起使用的RESTFul服务框架(GWT)和移动(Android)客户端。尽管 Restlet 似乎为AppEngine,GWT和Android提供了版本,但到目前为止,我已经将其降至 RestEasy 主要由于此问题

以前有一些问题,讨论RESTFul框架 a>但我认为这种比较不适用于此,现在很常见。听到有经验的开发人员对这套平台可用的框架以及优点和缺点的看法是有帮助的。

解决方案

您可能希望考虑使用 Google Cloud Endpoints ,它在Google I / O上被宣布为App Engine的受信任测试程序功能,现在每个人都可以使用它。借助端点,您可以注释简单的Java(或Python)类和方法来描述您的API。例如,这是一个简单的类,用于从井字游戏中获取和检索高分列表:

  @Api (name =tictactoe)
public class ScoreEndpoint {
@ApiMethod(name =scores.get)
public Sc​​ore get(@Named(id)String id){
PersistenceManager pm = getPersistenceManager();
分数分数= pm.getObjectById(Score.class,id);
pm.close();
的回报分数;
}

@ApiMethod(name =scores.list)
public List< Score> list(){
PersistenceManager pm = getPersistenceManager();
Query query = pm.newQuery(Score.class);
return(List< Score>)pm.newQuery(query).execute();


$ / code $ / pre
$ b

特征




  • 支持Java和Python运行时

  • 基于Google API基础架构与许多用于Google自己的API的相同工具和库一起工作,例如 API Explorer API控制台

  • 自动生成的静态类型适用于Android和iOS的客户端库 - 这些库使用与Google相同的 Java Objective-C 库用于访问其他Google提供的API,例如Calendar API
  • 动态类型的JS客户端库 - 同样,用于访问JS中由Google提供的其他API的相同库

  • 内置对OAuth 2的支持

  • 与Google Plugin for Eclipse集成 - 这允许您自动创建基于模型的API或App Engine应用程序来备份现有的Android应用程序

  • 支持本地开发 - 您可以使用App Engine开发环境构建和测试您的API,就像其他App Engine功能一样



了解详情



查看文档了解有关使用端点的更多详细信息。



您还可以观看Google I / O的几次会谈:




I am working on a project that involves mobile and web clients with Google's AppEngine PAAS. I would like to use RESTFul webservices with my AppEngine app.

I have looked over Stackoverflow for references to RESTFul service frameworks that can be used with AppEngine for both web (GWT) and mobile (Android) clients. Although Restlet seems to provide editions for AppEngine, GWT and Android, so far I've got it down to RestEasy mostly due to this question.

There have been questions previously that discuss RESTFul frameworks but I don't think the comparisons apply well to this, now quite common, case. It would be helpful to hear experienced developers' views on the frameworks available for this set of platforms and merits versus demerits of each.

解决方案

You might wish to consider using Google Cloud Endpoints, which was announced as a trusted tester feature for App Engine at Google I/O, and is now available to everyone. With Endpoints, you annotate simple Java (or Python) classes and methods to describe your API. For example, this is a simple class to get and retrieve a list of high scores from a Tic Tac Toe game:

@Api(name = "tictactoe")
public class ScoreEndpoint {
  @ApiMethod(name = "scores.get")
  public Score get(@Named("id") String id) {
    PersistenceManager pm = getPersistenceManager();
    Score score = pm.getObjectById(Score.class, id);
    pm.close();
    return score;
  }

  @ApiMethod(name = "scores.list")
  public List<Score> list() {
    PersistenceManager pm = getPersistenceManager();
    Query query = pm.newQuery(Score.class);
    return (List<Score>) pm.newQuery(query).execute();
  }
}

Features

  • Support for Java and Python runtimes
  • Built on Google's API infrastructure - it works with many of the same tools and libraries used for Google's own APIs, such as the APIs Explorer and APIs Console
  • Automatically-generated, statically-typed client libraries for Android and iOS - these libraries are using the same Google-authored Java and Objective-C libraries you would use to access other Google-provided APIs such as the Calendar API
  • Dynamically-typed JS client library - again, the same library you use to access other Google-provided APIs in JS
  • Built in support for OAuth 2
  • Integration with the Google Plugin for Eclipse - this allows you to automatically create an API based on a model, or an App Engine application to back an existing Android app
  • Support for local development - you can build and test your API using the App Engine development environment, just as with other App Engine features

Learn More

Check out the documentation for more details on using Endpoints.

You can also watch several talks from Google I/O:

这篇关于用于AppEngine的RESTFul服务框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆