Пример #1
0
        public IActionResult Start(string serverId, [FromBody] string secret, [FromQuery] ushort port)
        {
            if (!string.Equals(secret, _secret))
            {
                return(Forbid("Authentication error.")); // again, all of these are temporary
            }
            var server = _servers.GetServer(serverId);

            if (server == null)
            {
                return(BadRequest(new ServerStartStopResult
                {
                    Error = true,
                    Id = serverId,
                    ErrorMessage = "Server not found."
                }));
            }

            _logger.LogInformation($"Starting server with id {serverId}, port: {port}");
            return(Json(server.Start(port)));
        }