yohei-y:weblog

XML と REST/Web サービス関連の話題が中心の weblog です

2005-03-08

RESTful 英辞郎

英辞郎の REST インターフェースを考えてみた。非常にもっともらしい URL やホスト名や名前空間を使ってますが、完全にフィクションなのでそこのところをよろしく。

restful という単語を検索

GET /?word=restful HTTP/1.1
Host: rest.alc.co.jp

結果は一つ

HTTP/1.1 OK
Content-Type: application/xml

<?xml version="1.0"?>
<result-list xmlns="http://ns.alc.co.jp/eijiro">
  <word>restful</word>
  <count>12</count>
  <result>
    <pronounciation>レストゥフル</pronounciation>
    <pronounciation>レストフル</pronounciation>
    <basic-block><block>rest</block><block>ful</block></basic-block>
    <acceptation type="adjective">休息を与える</acceptation >
    <acceptation type="adjective">安らかな </acceptation>
  </result>
  <result>
  ...
</result-list>

rest という単語を検索

GET /?word=rest HTTP/1.1
Host: rest.alc.co.jp

結果はたくさん

HTTP/1.1 OK
Content-Type: application/xml

<?xml version="1.0"?>
<result-list xmlns="http://ns.alc.co.jp/eijiro">
  <word>restful</word>
  <count>3293</count>
  <result>
    <level>2</level>
    <pronounciation>re'st</pronounciation>
    <pronounciation type="kana">レスト</pronounciation>
    <inflections type="verb">rests resting rested</inflections>
    <item type="noun">
      <acceptation>休息</acceptation >
      <acceptation>睡眠</acceptation >
      <acceptation>眠り</acceptation >
      <acceptation>休養</acceptation >
      <acceptation>静養</acceptation >
      <acceptation>保養</acceptation >
      <example>
        <en>Get a good night's rest.</en>
        <ja>ゆっくりお休みなさい。</ja>
      </example>
      <example>
        <en>I think you'll need some rest.</en>
        <ja>君には少し休息が必要だ。</ja>
      </example>
    </item>
    <item type="intransitive verb">
      <acceptation>休む</acceptation>
      <acceptation>休息する</acceptation>
      <acceptation>休憩する</acceptation>
      <acceptation>休養する</acceptation>
      <acceptation>眠る</acceptation>
    </item>
    <item type="intransitive verb">
      <acceptation>静止する</acceptation>
    </item>
    <item type="intransitive verb">
      <acceptation>(物がある場所{ばしょ}に)ある</acceptation>
      <acceptation>置かれている</acceptation>
      <example>
        <en>Swans rest elegantly on the water.</en>
        <ja>水面には白鳥が優雅にたたずんでいる。</ja>
      </example>
    </item>
    <item type="intransitive verb">
      <acceptation>~次第である</acceptation>
    </item>
    ...
  </result>
  ...
  <next>http://rest.alc.co.jp/?word=rest&offset=50</next>
</result-list>

rest を検索で offset を 50 に指定

GET /?word=rest&offset=50 HTTP/1.1
Host: rest.alc.co.jp

結果が変わる

HTTP/1.1 OK
Content-Type: application/xml

<?xml version="1.0"?>
<result-list xmlns="http://ns.alc.co.jp/eijiro">
  <word>restful</word>
  <count>3293</count>
  <offset>50</offset>
  <result>
    ...
  </result>
  ...
  <next>http://rest.alc.co.jp/?word=rest&offset=100</next>
</result-list>

日本語の検索の例

GET http://rest.alc.co.jp/?word=レスト&ie=utf-8 HTTP/1.1

結果は面倒なので省略

ラベル: ,