代码之家  ›  专栏  ›  技术社区  ›  Hutch

Pragmas的工作方式似乎和我在海边预期的不同

  •  3
  • Hutch  · 技术社区  · 8 年前

    list
       <get>
    
    ^ String streamContents: [ :stream |
        self teamMembers do: [ :each |
           stream nextPutAll: each ; crlf ] ]
    

    WAAdmin注册:团队成员位于:“团队成员” http://localhost:8080/team-members )我收到了留言


    但如果我执行( http://localhost:8080/team-members/list ),它按预期工作。

    这似乎与中的文档相矛盾 http://book.seaside.st/book/advanced/restful/getting-started/define-handler

    如果我覆盖团队成员>&燃气轮机;

    createRoutes
        | route |
        route := WARoute get: '/listJson' selector: #listJson.
        ^OrderedCollection new
            "GET"
            add: route; 
            add: (WARoute get: #list); 
            yourself
    

    http://localhost:8080/team-成员

    然而,为了获得Json输出,我仍然必须使用( http://localhost:8080/team-members/listJson ).

    在Seaside中使用Pharo6.0-64.image,这就是Seaside的安装方式。

    Metacello new
      configuration:'Seaside3';
      repository: 
     'http://www.smalltalkhub.com/mc/Seaside/MetacelloConfigurations/main';
      version: #stable;
      load.
    
    
    Gofer new
      squeaksource: 'Seaside30Addons';
      package: 'Seaside-REST-Core';
      package: 'Seaside-Pharo-REST-Core';
      package: 'Seaside-Tests-REST-Core';
      load.
    

    谢谢

    2 回复  |  直到 8 年前
        1
  •  2
  •   Esteban A. Maringolo    8 年前

    <path: '/'> pragma,因为您有多个方法 <get>

        2
  •  2
  •   Hutch    8 年前

    似乎向list方法添加另一个pragma解决了这个问题。

    list
       <get>
       <path: '/'>
    
       ^ String streamContents: [ :stream |
            self teamMembers do: [ :each |
               stream nextPutAll: each ; crlf ] ]
    
    推荐文章