NetPro.Web.Api 6.0.5-beta.2

This is a prerelease version of NetPro.Web.Api.
There is a newer version of this package available.
See the version list below for details.
dotnet add package NetPro.Web.Api --version 6.0.5-beta.2
NuGet\Install-Package NetPro.Web.Api -Version 6.0.5-beta.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NetPro.Web.Api" Version="6.0.5-beta.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NetPro.Web.Api --version 6.0.5-beta.2
#r "nuget: NetPro.Web.Api, 6.0.5-beta.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install NetPro.Web.Api as a Cake Addin
#addin nuget:?package=NetPro.Web.Api&version=6.0.5-beta.2&prerelease

// Install NetPro.Web.Api as a Cake Tool
#tool nuget:?package=NetPro.Web.Api&version=6.0.5-beta.2&prerelease

NetPro.Web.Api使用

NuGet

封装了基本asp.netcore webapi工程需要的基本功能

安装

  • Package Manager方式: Install-Package NetPro.Web.Api -Version 3.1.2

  • .NET CLI 方式: dotnet add package NetPro.Web.Api --version 3.1.2

  • PackageReference: <PackageReference Include="NetPro.Web.Api" Version="3.1.2" />

  • .NET CLI 方式: paket add NetPro.Web.Api --version 3.1.2


支持以下几种开发方式

1、简化版

API主程序集下每个业务模块一个文件夹隔离,业务模块下包含此业务模块的Controller、Service、Entity等等

2、程序集隔离

每个业务模块一个程序集,每个程序集中包含当前业务模块需要的所有Controller、Service、Entity等等,再API主程序集引用需要的业务模块,业务模块之间尽可能不互相依赖,引用。

3、插件方式

2、程序集隔离的基础上,API主程序集不直接引用需要的业务模块程序集,而是将各业务模块程序集放置在指定的插件文件夹中,插件路径配置如下:

"TypeFinderOption": {
		"MountePath": ""//windows默认目录: C:/opt/netpro ; linux环境:/opt/netpro
	},

注意

引用程序集会自动注入相关服务,无需再进行Service.Add..();

使用

appsetting.json
      //按需要配置以下节点,可忽略
      "NetProOption": {
		//"UseResponseCompression": false, //是否启用响应压缩
		//"ThreadMinCount": 5, //最小线程数
		//"ApplicationName": "", //应用名称
		//"RequestWarningThreshold": 5, //请求时长的警告临界值
		//"RoutePrefix": "api" //全局路由前缀
	},

内置中间件与系统中间件的映射关系:


public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
	
    app.UseExceptionHandler();   //对应ErrorHandlerStartup
    
	// your code
	...//此区间请求管道上的Order取值 范围0-100

    app.UseStaticFiles();        //对应StaticFilesStartup

	// your code
	...//此区间请求管道上的Order取值 范围101-200

    app.UseRouting();            //对应RoutingStartup

    // your code
	...//此区间请求管道上的Order取值 范围200-1000

    app.UseEndpoints(endpoints =>//对应EndpointsStartup
    {
        endpoints.MapRazorPages();
    });
}

考虑到灵活性,Netpro.Web.APi不包含UseEndpoints处理,如果不是通过脚手架生成NetPro项目,需要手动增加以下文件EndpointsStartup.cs到项目中

// <auto-generated>
//  UseEndpoints   
// </auto-generated>

using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace NetPro.Web.Api
{
    /// <summary>
    /// Endpoints 
    /// </summary>
    public class EndpointsStartup : INetProStartup
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="services"></param>
        /// <param name="configuration"></param>
        /// <param name="typeFinder"></param>
        public void ConfigureServices(IServiceCollection services, IConfiguration configuration, TypeFinder.ITypeFinder typeFinder)
        {

        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="application"></param>
        public void Configure(IApplicationBuilder application)
        {
            application.UseEndpoints(s =>
            {
                s.MapControllers();//add other operation
            });
        }

        /// <summary>
        /// UseEndpoints should be loaded last
        /// </summary>
        public double Order { get; set; } = 1000;
    }
}

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on NetPro.Web.Api:

Repository Stars
LeonKou/NetPro
🌈An enhanced version with clean architecture of asp.netcore,efficiently manage startup,Support for netcore3.1/6.0
Version Downloads Last updated
6.0.16 231 7/24/2023
6.0.15 711 7/19/2022
6.0.14 444 7/10/2022
6.0.13 469 6/15/2022
6.0.12 390 6/15/2022
6.0.11 384 6/15/2022
6.0.10 409 6/11/2022
6.0.9 413 6/8/2022
6.0.8 444 5/26/2022
6.0.8-beta.3 138 5/24/2022
6.0.8-beta.2 110 5/24/2022
6.0.7 417 5/18/2022
6.0.6 425 4/28/2022
6.0.5 427 3/30/2022
6.0.5-beta.20 102 4/27/2022
6.0.5-beta.19 114 4/25/2022
6.0.5-beta.18 108 4/22/2022
6.0.5-beta.17 123 4/16/2022
6.0.5-beta.16 189 4/8/2022
6.0.5-beta.15 112 4/8/2022
6.0.5-beta.14 124 4/7/2022
6.0.5-beta.13 117 4/7/2022
6.0.5-beta.12 114 4/6/2022
6.0.5-beta.11 144 4/6/2022
6.0.5-beta.10 136 3/31/2022
6.0.5-beta.9 128 3/26/2022
6.0.5-beta.8 150 3/22/2022
6.0.5-beta.7 127 3/21/2022
6.0.5-beta.6 133 3/14/2022
6.0.5-beta.5 132 3/2/2022
6.0.5-beta.4 137 2/22/2022
6.0.5-beta.3 129 2/18/2022
6.0.5-beta.2 118 2/18/2022
6.0.5-beta.1 123 2/16/2022
6.0.4 451 2/10/2022
6.0.3 450 2/9/2022
6.0.3-beta.9 114 2/10/2022
6.0.3-beta.8 142 1/27/2022
6.0.3-beta.7 137 1/19/2022
6.0.3-beta.6 137 1/17/2022
6.0.3-beta.5 123 1/17/2022
6.0.3-beta.4 136 1/16/2022
6.0.3-beta.3 130 1/14/2022
6.0.3-beta.2 128 1/13/2022
6.0.3-beta.1 159 1/11/2022
6.0.2 312 1/6/2022
6.0.1 986 12/3/2021
3.1.11 441 11/19/2021
3.1.10 1,143 7/29/2021
3.1.9 1,069 7/1/2021
3.1.8 1,058 12/15/2020
3.1.6 1,206 9/16/2020
3.1.5 1,095 9/8/2020
3.1.4 1,263 6/30/2020
3.1.3 1,170 6/23/2020
3.1.2 1,332 5/26/2020
3.1.1 1,172 5/26/2020
3.1.0 1,217 5/24/2020
1.0.1 1,315 5/4/2020
1.0.0 1,180 4/27/2020