Reputation: 5000
Let's say I have a dozen microservices. I am wondering where should the front end go. Let's say front end is HTML, Javascript, CSS. One way is to make it a separate service handled by a UI team. So it can form the API gateway where the request from browser comes in first. But this seems against the idea of independent self contained services.
browser ------> API Gateway ------> Microservices
In this link, they say that Javascript and CSS should be served by microservices. API gateway should serve only the HTML page. THere is a nice diagram showing this >>
I have two questions
1. How will this be implemented? How will API gateway serve the JS and CSS files in microservices, and maybe HTML fragments too. How will initial page load happen and from where.
2. Now we are mingling HTML into microservices. But what if I want to serve Android and iOS apps too? THanks.
Upvotes: 6
Views: 1412
Reputation: 4025
let me try to answer your 2 questions directly without discussing either approaches.
Modular Web Apps are possible if you use an MV* pattern. AngularJS and ReactJS both support building modular Apps and load modules on demand via webpack or requireJs.
Since your UI is composed of fragments coming from different microservices, you might need a reverse proxy and some CDN or caching to speed up page load by curating client requests to a single host (domain).
Native Apps will require an API layer and you can curate your microservices into a single API gateway, maybe even develop a mediator API between mobile apps and actual microservices to expose only a simple subset of your actual backend.
Upvotes: 1