コード例 #1
0
        public PlaneApiModule(FsxDataRepository fsxDataRepository)
        {
            _fsxDataRepository = fsxDataRepository;

            Get["/api/plane"] = parameters =>
            {
                Console.WriteLine("GET /api/plane");

                var plane = new Plane
                {
                    Position = _fsxDataRepository.GetPlanePosition(),
                    Speed = _fsxDataRepository.GetPlaneSpeed()
                };

                return Response.AsJson(plane);
            };

            Get["/api/plane/position"] = parameters =>
            {
                Console.WriteLine("GET /api/plane/position");

                var planePosition = _fsxDataRepository.GetPlanePosition();

                return Response.AsJson(planePosition);
            };

            Get["/api/plane/speed"] = parameters =>
            {
                Console.WriteLine("GET /api/plane/speed");

                var planeSpeed = _fsxDataRepository.GetPlaneSpeed();

                return Response.AsJson(planeSpeed);
            };
        }
コード例 #2
0
        public PlaneApiModule(FsxDataRepository fsxDataRepository)
        {
            _fsxDataRepository = fsxDataRepository;

            Get["/api/plane"] = parameters =>
            {
                Console.WriteLine("GET /api/plane");

                var plane = new Plane
                {
                    Position = _fsxDataRepository.GetPlanePosition(),
                    Speed    = _fsxDataRepository.GetPlaneSpeed()
                };

                return(Response.AsJson(plane));
            };

            Get["/api/plane/position"] = parameters =>
            {
                Console.WriteLine("GET /api/plane/position");

                var planePosition = _fsxDataRepository.GetPlanePosition();

                return(Response.AsJson(planePosition));
            };

            Get["/api/plane/speed"] = parameters =>
            {
                Console.WriteLine("GET /api/plane/speed");

                var planeSpeed = _fsxDataRepository.GetPlaneSpeed();

                return(Response.AsJson(planeSpeed));
            };
        }