Exemple #1
0
 private void SendHello(EndpointRequestData requestData)
 {
     requestData.Context.Response.SendResponse(new MessageDto
     {
         Message = "Hello " + requestData.PathParameters["name"]
     }.ToJson());
 }
Exemple #2
0
 private static void SendNoEndpointFound(EndpointRequestData requestData)
 {
     requestData.Context.Response.SendResponse(new ErrorMessageDto
     {
         ErrorMessage = $"No endpoint found for '{requestData.Context.Request.HttpMethod}' on '{requestData.Context.Request.RawUrl}'. "
                        + "Try 'GET' on 'api/rest/endpoints' to get the available endpoints."
     }.ToJson(), HttpStatusCode.NotFound);
 }
Exemple #3
0
 private void SendRegisteredEndpoints(EndpointRequestData requestData)
 {
     requestData.Context.Response.SendResponse(new EndpointListDto
     {
         Endpoints = GetRegisteredEndpoints()
                     .Select(endpoint => new EndpointDto
         {
             HttpMethod  = endpoint.HttpMethod.Method,
             UrlPattern  = endpoint.UrlPattern,
             Description = endpoint.Description
         })
                     .ToList()
     }.ToJson());
 }
Exemple #4
0
    private void SendLoadedSongs(EndpointRequestData requestData)
    {
        SongMetaManager songMetaManager = SongMetaManager.Instance;

        requestData.Context.Response.SendResponse(new LoadedSongsDto
        {
            IsSongScanFinished = SongMetaManager.IsSongScanFinished,
            SongCount          = songMetaManager.GetSongMetas().Count,
            SongList           = songMetaManager.GetSongMetas()
                                 .Select(songMeta => new SongDto
            {
                Artist = songMeta.Artist,
                Title  = songMeta.Title,
                Hash   = songMeta.SongHash,
            })
                                 .ToList()
        }.ToJson());
    }