FokiDoki / WireRest

REST API for Wireguard
MIT License
18 stars 5 forks source link

Added sorting and paging to /peers end point #37

Closed FokiDoki closed 1 year ago

FokiDoki commented 1 year ago

Now /peers endpoint have 3 optional params: limit - Max peers per page page - Number of page sort - Sort key and direction separated by a dot. The keys are the same as in the answer. Direction is optional and may have value DESC (High to low) and ASC (Low to high). Default is DESC. Sort available for any key

Example request:

curl -X 'GET' \ 'http://localhost:8080/peers?page=2&limit=2' \ -H 'accept: application/json'

Answer

> [ > { > "publicKey": "PubKey7", > "presharedKey": "presharedKey7", > "endpoint": null, > "allowedIps": [ > "10.0.0.6/32" > ], > "latestHandshake": 100000, > "transferRx": 12345, > "transferTx": 54321, > "persistentKeepalive": 0 > }, > { > "publicKey": "PubKey8", > "presharedKey": "presharedKey8", > "endpoint": null, > "allowedIps": [ > "10.0.0.7/32" > ], > "latestHandshake": 200000, > "transferRx": 12345, > "transferTx": 54321, > "persistentKeepalive": 0 > } > ]