当前位置: 首页 > 知识库问答 >
问题:

对谷歌云endpoint的理解?

秦鹏飞
2023-03-14

云-endpoint。
我正在学习Udacity教程。我对请求和响应的流程有点混淆,下面是我的理解
endpoint应该用@api注释,endpoint方法应该用@apimethod注释,这些方法不应该返回原始数据类型。下面是一个endpoint方法

@ApiMethod(name = "saveProfile", path = "profile", httpMethod = HttpMethod.POST)

public Profile saveProfile(ProfileForm profileForm) throws UnauthorizedException {

    String userId = null;
    String mainEmail = null;
    String displayName = "Your name will go here";
    TeeShirtSize teeShirtSize = TeeShirtSize.NOT_SPECIFIED;

    if(profileForm.getTeeShirtSize() != null)
        teeShirtSize = profileForm.getTeeShirtSize();

    displayName = profileForm.getDisplayName();

    Profile profile = new Profile(userId, displayName, mainEmail, teeShirtSize);

    return profile;
}


下面是我的ProfileForm和Profile类

public class ProfileForm {
private String displayName;

private TeeShirtSize teeShirtSize;

private ProfileForm () {}

    public ProfileForm(String displayName, TeeShirtSize teeShirtSize) {
    this.displayName = displayName;
    this.teeShirtSize = teeShirtSize;
}

public String getDisplayName() {
    return displayName;
}

public TeeShirtSize getTeeShirtSize() {
    return teeShirtSize;
}

public static enum TeeShirtSize {
    NOT_SPECIFIED,
    XS,
    S,
    M,
    L, 
    XL, 
    XXL,
    XXXL
  }
}


public class Profile {
String displayName;
String mainEmail;
TeeShirtSize teeShirtSize;


String userId;

    public Profile (String userId, String displayName, String mainEmail, TeeShirtSize teeShirtSize) {
    this.userId = userId;
    this.displayName = displayName;
    this.mainEmail = mainEmail;
    this.teeShirtSize = teeShirtSize;
}

public String getDisplayName() {
    return displayName;
}

public String getMainEmail() {
    return mainEmail;
}

public TeeShirtSize getTeeShirtSize() {
    return teeShirtSize;
}

public String getUserId() {
    return userId;
}

    private Profile() {}

}

共有1个答案

闾丘诚
2023-03-14

我用的是1.9.3版本的google-app-engine,然后我改成了1.9.20,现在它工作得很好。但我仍然想问一些问题,比如为什么它不能在1.9.3中运行?
谢谢

 类似资料:
  • 我尝试过将deendpoint与云SQL和Hibernate集成。但是,每次都有错误。跟随我的测试: 1 -源文件夹中的persistence . XML:http://imgur.com/hKjf8Cs给我错误:http://imgur.com/QJe8rvq 2-资源文件夹中的persistence.xml给我错误: ServletInitializationParameters.java:5

  • 我有一个来自endpoint原始数据存储API的endpoint模型,称为资源,我使用Resource.query(). fetch(10)请求10个项目。 问题是它返回一个资源数组,但根据“创建endpointAPI”的文档,我需要返回一个消息数组。 https://cloud.google.com/appengine/docs/python/endpoints/create_api 使用Goo

  • 我正在使用这个链接构建一个使用GCM的简单聊天应用程序,我发现了这个伟大的特性“Google Cloud Endpoints”,它使事情变得更容易。但我不敢依赖它,因为我注意到它仍然是试验性的。我可以信任它还是应该使用Java servlet?

  • 尝试运行本地开发服务器时 我正在尝试解决打开zip文件或JAR清单时出错:C:\Program 但是我应该在哪里以及如何改变默认的-javaAgent:?

  • 尝试访问< code > http://localhost:8080/_ ah/API 时,我得到一个< code > StringIndexOutOfBoundsException : java.lang.String索引超出边界异常: 字符串索引超出范围: 0 at Java . lang . string . charat(string . Java:658)at com . Google

  • 介绍如何在谷歌云平台获取在云联壹云平台需要使用的配置参数。 如何获取谷歌云服务帐号密钥信息? 纳管指定项目 打开“GCP Console中的IAM和管理-IAM页面”页面并登录。 单击顶部“选择项目”,选择需要授权的项目。 在左侧导航栏中选择“服务账号”,进入指定项目的服务账号页面。 单击 “创建服务账号” 按钮,进入创建服务账号页面。 配置服务账号名称、服务账号ID、服务账号说明等,单击 “创建