This repository contains all the demos run during the Designing a UI for Microservices
talk.
ViewModel Composition is deeply discussed on my blog in the ViewModel Composition category.
- Visual Studio 2017 with .NET Core 2.2.x support (Community Edition is supported), available for download at https://www.visualstudio.com/downloads/
The ASP.Net Core API Gateway
, 01 and 02, solution demos ViewModel Composition techniques built on top of .Net Core.
CompositionGateway
project shows how to create and host a .Net Core API Gateway, or reverse proxy, that composes HTTP requests to multiple API backends.
To run this sample ensure that the following projects are set as startup projects:
Sales.Api
Shipping.Api
Warehouse.Api
Catalog.Api
CompositionGateway
As client to test the funzionality a REST client such as Postman can be used.
ASP.Net Core API Gateway - 01
demoes how single items composition worksASP.Net Core API Gateway - 02
demoes how single items and items list composition works
The postman-collection.json file can be imported into Postman, creating a collection with all the HTTP requests needed to test both demos.
WebApp
project is a .Net Core Mvc app that composes HTTP requests to multiple backends directly in Mvc Views as Controllers are invoked. This demo implements ViewModel Composition concepts introducing the concept of Branding as a contract at the UI level.
To run this sample ensure that the following projects are set as startup projects:
Sales.Api
Shipping.Api
Warehouse.Api
Catalog.Api
WebApp
WebApp
project is a .Net Core Mvc app that composes HTTP requests to multiple backends directly in Mvc Views as Controllers are invoked. This demo implements ViewModel Composition and UI Composition concepts.
To run this sample ensure that the following projects are set as startup projects:
Sales.Api
Shipping.Api
Warehouse.Api
Catalog.Api
WebApp
To simplify as much as possible the sample, frontend applications, such as CompositionGateway
and WebApp
, directly reference ViewModel Composition and UI Composition assemblies. This allows also to avoid the usage of Visual Studio post build events, that at the time of this writing are affected by a bug when used in combination with .NET Core, causing events variable to not be populated as expected.
A workaround is to use a MSBuild
Exec
task to simulate post build events. E.g. in order to try to run samples removing all hard-coded references:
- Remove references to composition assemblies from
CompositionGateway
andWebApp
project(s) - Edit the project file of composition assemblies that need to be copied to
CompositionGateway
andWebApp
output folders by adding the following to each of them:
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="
copy "$(TargetDir)$(TargetName).dll" "$(SolutionDir)CompositionGateway\$(OutDir)$(TargetName).dll" /Y /B
copy "$(TargetDir)$(TargetName).pdb" "$(SolutionDir)CompositionGateway\$(OutDir)$(TargetName).pdb" /Y /B" />
</Target>
Replacing CompositionGateway
with WebApp
for the last 2 demos.
NOTE:
- All solutions are configured to use the SwitchStartupProject Visual Studio Extension to manage startup projects. The extension is not a requirement, but it's comfortable.