Esempio n. 1
0
        public void ExposerManager_ExecuteService()
        {
            //Arrange
            ExecuteExposerDto dto = new ExecuteExposerDto();

            dto.HttpMethod  = "GET";
            dto.Path        = "";
            dto.RequestBody = "";
            dto.Headers.Add(new HeaderDto()
            {
                Name = "Authorization", Value = "Basic 90eruqr98uqr89jfodi"
            });

            //Act


            //Assert
        }
Esempio n. 2
0
        public ExposerResultDto ExecuteExposer(ExecuteExposerDto dto)
        {
            Exposer exposer = _exposerRepository.GetByPath(dto.Path);

            if (exposer == null)
            {
                throw new ExposerDoesNotExistException();
            }

            IList <Header> headers = new List <Header>();

            foreach (var h in dto.Headers)
            {
                headers.Add(new Header(h.Name, h.Value));
            }

            switch (exposer.Service.ServiceType)
            {
            case ServiceType.DUMMY:
                return(null);

            case ServiceType.REST:
                RestService         restService = _jsonSerializer.Deserialize <RestService>(exposer.Service.JsonDetails);
                RestServiceRequest  request     = new RestServiceRequest(restService, dto.HttpMethod, headers, dto.RequestBody);
                RestServiceResponse response    = _restServiceExecutor.Execute(request);

                return(response.ToDto());

            case ServiceType.SOAP:
                return(null);

            case ServiceType.DATABASE:
                return(null);

            default:
                return(null);
            }
        }
Esempio n. 3
0
        public void ProcessRequest()
        {
            try
            {
                ExecuteExposerDto dto = new ExecuteExposerDto();
                dto.Path        = Request.Path;
                dto.HttpMethod  = Request.Method;
                dto.RequestBody = BodyToString(Request.Body);
                ExposerResultDto resultDto = _exposerManager.ExecuteExposer(dto);

                Response.StatusCode  = resultDto.StatusCode;
                Response.ContentType = "application/json";

                Response.Body.WriteAsync(Encoding.UTF8.GetBytes(resultDto.Body), 0, resultDto.Body.Length);
            }
            catch (ExposerDoesNotExistException e)
            {
                Response.StatusCode = 404;
            }
            catch (Exception e)
            {
                Response.StatusCode = 500;
            }
        }