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

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.

主站蜘蛛池模板: 彭州市| 大宁县| 北宁市| 瓦房店市| 德保县| 尚义县| 江陵县| 隆子县| 宕昌县| 田林县| 万源市| 潼南县| 仪陇县| 曲靖市| 曲水县| 黄平县| 镇康县| 甘谷县| 凯里市| 武定县| 武宣县| 莱州市| 漠河县| 安国市| 收藏| 阳信县| 航空| 莱阳市| 卢龙县| 通渭县| 襄垣县| 英德市| 深州市| 长海县| 扎囊县| 离岛区| 赤峰市| 东兰县| 潜江市| 新和县| 永昌县|