Project overview---1

project structure

luanchSetting reflects the interface and other information of different operating modes (you can choose which mode to run at runtime)
appsetting.json global configuration file

project run

First, to run the project, ensure that the running box runs under EntityFramework. Both startup boxes must be changed.
Second, change the database connection field to your own in the appsettings file in the DbMigrator file and the appsettings file in the HttpApiHost project, and then enter it in the nuget package console. the following code

Add-Migration "init"
Update-Database

Complete datebase migration.
After running successfully, the asp.net core framework (restful style), swaggerUI, can clearly reflect all api interfaces and request response activities, and can also operate execute to realize interface function testing

restful style

According to the page display, each module is a part of resources, and each resource has its own url (resource identifier). The same url can perform many operations, not only request response
to multiple accesses to the same rest interface, the obtained resource status is identical.
Access to the interface will not change the server status

Multiple ways to call coreapi

Browser url access
swagger access
Background simulation request access

routing

【】Inside
is equivalent to a label
, which is based on the method that can be selected under the same resource.
Each API must specify a characteristic route, that is, mark the access API on the API or controller
according to this format: Route("api/[Controller ]/Api)
A controller can define multiple API methods, which are distinguished by routing rules
Key words: routing constraints
If the constraints do not meet the conditions, the server cannot be requested, but without constraints, the server will be requested, and then an error occurs
eg :controller:int

Nature

Encapsulate response and request into Httpcontext and present it to the application layer, and implement the project through Host hosting.
Build the common services of asppsetting log

program.cs

Enable content root directory – configure – start kiesrel server – parameter configuration – log configuration – service injection – use middleware – return a builder – complete packaging – build the packaged things

dependency injection

From primitive society to industrial society, the identity of the caller has changed from ourselves to a factory.
Three injection methods: constructor injection, property injection, method injection
Three life cycles: AddSingleton
AddTransient
AddScoped

Acho que você gosta

Origin blog.csdn.net/weixin_45139296/article/details/131047745
Recomendado
Clasificación