Esempio n. 1
0
        /// <inheritdoc />
        public void Attach(IEndpointRouteBuilder routeBuilder, IInternalApiConfiguration apiConfig,
                           IServiceProvider scopedProvider)
        {
            var endPointList = apiConfig.GetEndPointHandlers();

            foreach (var methodHandlerPair in endPointList)
            {
                foreach (var methodHandler in methodHandlerPair.Value.Values)
                {
                    routeBuilder.MapMethods(methodHandler.RouteInformation.RouteTemplate,
                                            new[] { methodHandler.HttpMethod }, methodHandler.HandleRequest);
                }
            }
        }
Esempio n. 2
0
        /// <inheritdoc />
        public virtual void Attach(IApplicationBuilder builder, IInternalApiConfiguration apiConfig, IServiceProvider scopedProvider)
        {
            _unmappedEndPointHandler = scopedProvider.GetService <IUnmappedEndPointHandler>();

            var endPoints = CreateEndPointDictionary(apiConfig, _unmappedEndPointHandler);

            var routeBuilder = scopedProvider.GetService <IInternalEndPointRouteBuilder>();

            _endPointHandlers = routeBuilder.BuildRouteFunc(endPoints);

            builder.Use(requestDelegate =>
            {
                _requestDelegate = requestDelegate;

                return(Execute);
            });
        }
Esempio n. 3
0
        /// <inheritdoc />
        public void Configure(IInternalApiConfiguration apiInformation, IReadOnlyList <IEndPointMethodHandler> endPointMethodHandlersList)
        {
            var documentationOptions = _configurationManager.GetConfiguration <DocumentationOptions>();

            _enabled = documentationOptions.Enabled;

            if (_enabled)
            {
                _redirect     = documentationOptions.RedirectRootToDocumentation;
                _jsonDataPath = documentationOptions.UIBasePath + documentationOptions.OpenApiJsonUrl;
                _pathBase     = documentationOptions.UIBasePath;

                _openApiGenerationService.Configure(documentationOptions, endPointMethodHandlersList);

                //_swaggerAssetProvider.Configure(documentationOptions);
            }
        }
Esempio n. 4
0
        protected virtual IDictionary <string, IEndPointHandler> CreateEndPointDictionary(
            IInternalApiConfiguration apiConfig, IUnmappedEndPointHandler unmappedEndPointHandler)
        {
            var endPointMethodHandlersDictionary = apiConfig.GetEndPointHandlers();

            var list = endPointMethodHandlersDictionary.SelectMany(pair => pair.Value.Values).ToList();

            _unmappedEndPointHandler.Configure(apiConfig, list);

            var endPointHandlerDictionary = new Dictionary <string, IEndPointHandler>();

            foreach (var kvp in endPointMethodHandlersDictionary)
            {
                var valuesList = kvp.Value.Values.ToList();

                var anyParameters = valuesList.Any(h => h.RouteInformation.Tokens.Count > 0);

                endPointHandlerDictionary[kvp.Key] = new HttpMethodEndPointHandler(kvp.Key, anyParameters, valuesList, _unmappedEndPointHandler);
            }

            return(endPointHandlerDictionary);
        }
Esempio n. 5
0
 public HttpMethodConfiguration(IInternalApiConfiguration internalApiConfiguration)
 {
     _internalApiConfiguration = internalApiConfiguration;
 }
Esempio n. 6
0
 /// <inheritdoc />
 public void Configure(IInternalApiConfiguration apiInformation, IReadOnlyList <IEndPointMethodHandler> endPointMethodHandlersList)
 {
 }