簡單 web 服務與客戶端開發實戰 複製SWAPI網站 api文件
阿新 • • 發佈:2018-12-13
專案github地址如下
https://github.com/BigBrother3
本篇文件主要是展示一下專案中的api
查詢資源api
直接用get請求 http://localhost:8080/api/films/1 ,就可以得到資源。
資源的api主要有
總的api,預設返回第一頁的內容,每頁有5個資源
http://localhost:8080/api/films http://localhost:8080/api/people http://localhost:8080/api/planets http://localhost:8080/api/species http://localhost:8080/api/starships http://localhost:8080/api/vehicles
按頁搜尋的api,每頁有5個資源
http://localhost:8080/api/films/?pages=%d
http://localhost:8080/api/people/?pages=%d
http://localhost:8080/api/planets/?pages=%d
http://localhost:8080/api/species/?pages=%d
http://localhost:8080/api/starships/?pages=%d
http://localhost:8080/api/vehicles/?pages=%d
按個搜尋的api
http://localhost:8080/api/films/%d http://localhost:8080/api/people/%d http://localhost:8080/api/planets/%d http://localhost:8080/api/species/%d http://localhost:8080/api/starships/%d http://localhost:8080/api/vehicles/%d
註冊使用者api
向http://localhost:8080/register 傳送post請求,並將使用者名稱和密碼的資訊發出,就可以看到服務端返回成功的字樣。
登陸使用者api
向http://localhost:8080/login 傳送post請求,並將之前註冊的使用者名稱和密碼發出,可以看到伺服器傳回來一個token,通過這個toke就可以驗證使用者是否登陸了。