Exemple #1
0
        public static HttpResponseMessage Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "v1/subwayLines/{color}")]
            HttpRequestMessage req,
            string color,
            TraceWriter log)
        {
            // TODO: validate input
            // TODO: move serialization into service
            // TODO: enum for colors
            // TODO: consolidate with commuter rail?
            // TODO: OpenAPI Spec
            // TODO: functional tests
            // move auth error into functional tests

            var authError = AuthSvc.GetAuthenticationError(req);

            if (authError != null)
            {
                return(authError);
            }

            var      colorCleaned     = color.ToLower();
            string   directionCleaned = GetRequestParam <string>(req, "direction").ToLower();
            DateTime timeOfTravel     = GetRequestParam <DateTime>(req, "timeOfTravel");
            bool?    isWeekend        = GetRequestParam <bool?>(req, "isWeekend");

            var answer = BikeTheTSvc.BikesAllowedOnSubway(colorCleaned, directionCleaned, timeOfTravel, isWeekend);

            return(CreateResponse(colorCleaned, directionCleaned, timeOfTravel, isWeekend, answer));
        }