Reworked Lavalink REST Handling
Created by: Neuheit
Summary
I recently discovered that there are 3 other Lavalink endpoints that are not implemented yet. With those included that would leave a total of 7 endpoints. Because of this, I decided to implement the new endpoints and consolidate them all into one file.
Details
The new supported endpoints are:
GET /version
- Returns the current version of the server as a string.
GET /decodetrack
- Returns the audio track object based on an inputted Base64 track string parameter.
POST /decodetracks
- Returns a JSON array of audio track objects based on an inputted JSON array payload of Base64 track strings.
The server side decoding endpoints can be found starting here and the server side version endpoint can be found here.
In addition to these methods, I decided to combine all 7 handlers (including the route planner) into a LavalinkRest
class. This class is a property to the LavalinkNodeConnection
class (known as .Rest
), and the property is initialized in the LavalinkNodeConnection
class. The old handlers were also removed in several places, such as in LavalinkNodeConnection
and the LavalinkRoutePlanner
.
I also created a new endpoints class similar to the main one for D#+ so it makes it easier to change endpoints, as well as add new ones.
Changes proposed
- Added support for the 3 new endpoints described above.
- Consolidated all REST handlers into one class, and removed the old instances of them.
- Added a static Lavalink Endpoints class which contains the paths for all endpoints, allowing for it to be more modular.
- Changed LavalinkTrack to a class in order to be nullable in the event an internal server error occurs in
/decodetracks
.
Notes
This is a rather big, and breaking, change.