Esempio n. 1
0
        public void PutServerInfo(HttpListenerContext context)
        {
            var inpStream = new StreamReader(context.Request.InputStream);

            EndpointInfo.ServerInfo serverInfo =
                JsonConvert.DeserializeObject <EndpointInfo.ServerInfo>(inpStream.ReadToEnd());
            string endPoint = ReqExtracters.ExtractEndpoint(context.Request);

            _db.PutServerInfo(new EndpointInfo(endPoint, serverInfo));

            this.SendResponse(context.Response, "", HttpStatusCode.OK);
        }
Esempio n. 2
0
        public void GetServerInfo(HttpListenerContext context)
        {
            string endpoint = ReqExtracters.ExtractEndpoint(context.Request);

            EndpointInfo.ServerInfo serverInfo = _db.GetServerInfo(endpoint);

            if (serverInfo == null)
            {
                this.SendResponse(context.Response, "", HttpStatusCode.NotFound);
                return;
            }

            string serverInfoJson = JsonConvert.SerializeObject(serverInfo);

            this.SendResponse(context.Response, serverInfoJson, HttpStatusCode.OK);
        }