Mundane은 .NET를위한 가벼운 "No Magic"웹 프레임 워크입니다.
이 패키지를 사용하면 평범한 응용 프로그램을 ASP.NET과 함께 호스팅 할 수 있습니다.
자세한 내용은 평범한 문서를 참조하십시오.
Mundane.hosting.aspnet Nuget 패키지를 설치 한 다음 ASP.NET Startup Code Call app.UseMundane(); 라우팅 및 종속성 구성을 전달합니다.
public void Configure ( IApplicationBuilder app , IWebHostEnvironment env )
{
var dependencies = new Dependencies (
new Dependency < Configuration > ( new Configuration ( env ) ) ,
new Dependency < DataRepository > ( request => new DataRepositorySqlServer (
request . Dependency < Configuration > ( ) . ConnectionString ) ) ) ;
var routing = new Routing (
routeConfiguration =>
{
routeConfiguration . Get ( "/" , HomeController . HomePage ) ;
routeConfiguration . Get ( "/data/{id}" , DataController . GetData ) ;
routeConfiguration . Post ( "/data/{id}" , DataController . UpdateData ) ;
} ) ;
app . UseMundane ( dependencies , routing ) ;
} MundaneMiddleware.ExecuteRequest() 호출하여 ASP.NET 파이프 라인의 다른 부분에서 엔드 포인트를 실행할 수 있습니다. 예를 들어 평범한 엔진을 사용하면서 사용자 정의 오류 처리를 수행 할 수 있습니다.
현재 HttpContext 전달하고 라우팅 및 종속성 구성은 요청과 일치하는 엔드 포인트를 실행합니다.
public static async ValueTask ExecuteRequest (
HttpContext context ,
DependencyFinder dependencyFinder ,
Routing routing )다음과 같이 Specifc 엔드 포인트를 실행하는 것도 가능합니다.
public static async ValueTask ExecuteRequest (
HttpContext context ,
DependencyFinder dependencyFinder ,
MundaneEndpoint endpoint ,
Dictionary < string , string > routeParameters ) 종말점은 서명 ValueTask<Response> Endpoint(Request request) 가있는 MundaneEndpoint 여야합니다. 다른 평범한 엔드 포인트 서명은 MundaneEndpointFactory.Create() 호출하여 MundaneEndpoint 로 변환 할 수 있습니다.
MundaneEndpointFactory . Create ( ( ) => Response . Ok ( o => Write ( "Hello World!" ) ) ) ; 이 버전의 ExecuteRequest() 에는 라우팅 정보가 없으므로 엔드 포인트에 적절한 routeParameters 사전을 제공해야합니다. 파이프 라인의 일부로 호출되면 Mundane은 URL에서 캡처 한 매개 변수 사전, 예를 들어 /my-endpoint/{id} /my-endpoint/123 /{id}에 대한 routeParameters 만듭니다. Mundane은 new Dictionary<string, string> { { "id", "123" } } 통과합니다.
엔드 포인트에 경로 매개 변수가 필요하지 않은 경우 빈 사전을 전달하십시오. new Dictionary<string, string>(0); .