Esempio n. 1
0
        /// <summary>
        /// APIコントローラを実行する
        /// </summary>
        /// <param name="req">リクエスト情報</param>
        /// <param name="res">レスポンス情報</param>
        /// <param name="reqBody">リクエストボディ</param>
        /// <returns>レスポンス文字列</returns>
        private async Task <string> ExecuteController(HttpListenerRequest req, HttpListenerResponse res, string reqBody)
        {
            string path = ApiCommon.GetApiPath(req.RawUrl);

            if (path.StartsWith("/voiceroid/process"))
            {
                return(await VoiceroidProcess.Execute(req, res, reqBody));
            }
            else if (path.StartsWith("/voiceroid/task"))
            {
            }
            else if (path.StartsWith("/server"))
            {
                return(Server.Execute(req, res, reqBody));
            }
            else
            {
                res.StatusCode = 404;
            }

            /*
             * if ("/user/".Equals(path))
             * {
             *  switch (req.HttpMethod)
             *  {
             *      case "GET":
             *          return "";// (new ReadUserController(req, res, reqBody)).Execute();
             *      case "POST":
             *          return "";// (new CreateUserController(req, res, reqBody)).Execute();
             *      case "PUT":
             *          return "";// (new UpdateUserController(req, res, reqBody)).Execute();
             *      case "DELETE":
             *          return "";// (new DeleteUserController(req, res, reqBody)).Execute();
             *  }
             * }
             * if ("/users/".Equals(path) && "GET".Equals("GET"))
             * {
             *  return "";// (new ReadUsersController(req, res, reqBody)).Execute();
             * }
             */
            return("");
        }