官术网_书友最值得收藏!

Passing parameters to the API

One method of providing input to a REST API is via the calling URL, and this will be used to get a specified number of entries from the database using the following URL:

http://127.0.0.1:8080/api/quake/v1/recent/100

The implementation involves extending the pattern of the path with a curly bracket syntax (these correspond to the String parameters in the function):

  @ApiMethod(path: 'recent/{count}')
  Future<List<String>> recent(String count) async {
    DaoQuakeAPI quakeAPI = new DaoQuakeAPI();
    return await quakeAPI.fetchRecent(int.parse(count));
  }

The int.parse method is used to convert the count string into a database query parameter.

主站蜘蛛池模板: 遂宁市| 康平县| 南涧| 策勒县| 阿城市| 浙江省| 常山县| 海兴县| 长岭县| 石景山区| 阜新市| 青阳县| 奈曼旗| 上高县| 株洲县| 闸北区| 神木县| 聊城市| 门头沟区| 靖西县| 锡林郭勒盟| 永清县| 定陶县| 都匀市| 阿克苏市| 邳州市| 武穴市| 吕梁市| 璧山县| 团风县| 东源县| 苍梧县| 元氏县| 秦安县| 咸阳市| 资阳市| 理塘县| 莱州市| 阆中市| 军事| 崇仁县|