Spring Cloud - ZUUL API Gateway - uploading and downloading a csv (or any format) file? - spring

Using Spring Boot, I have tested the method described here to download a csv file by hitting the backend api.
Here the flow is simple: browser <--request/response--> backend api and the response headers (headers.set(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + csvFileName);) set by the backend api are directly interpreted by the browser and so it's straight forward.
But in my actual production environment, I have an API Gateway (ZUUL in my case) between browser and backend api. And I am not sure if the above approach will work when the request/response goes through api-gateway.
Can api-gateway's interpret the response headers and pass the same to the client i.e browser along with the data. Or any additional configuration is required.
Similarly does file uploads going through api-gateway to backend server need any additional consideration.

Related

zuul routing Strips request payload and attachment (SOAP - multipart\related) before sending to app backend

Our apps running on springBootVersion "2.3.1.RELEASE" . As per the framework requests hit zuul and are the routed to appropriate app backends. Apps backends are actually mule services. For one of the apps which accepts SOAP requests with attachment is having issues. When request is sent which is a POST request we could confirm both payload and attachment data in zuul DEBUG logs (Receiving Consumer request). But When it reaches the app side both payload and attachment data is missing (verified in app logs). Similar REST services with attachment where content type is multipart\formdata works without any issues. It's only with multipart\related content type we're having issues. Payload and attachment data/size looks fine. Any help on dealing multipart\related request ?
zuul config
servlet:
multipart:
max-file-size: 10MB
max-request-size: 10MB

How exactly Angular flows between Client and Server?

I was exploring about Angular 8 Recently and I am new to this technology. Here is what I understood..
You build your spring rest API project, and deploy that .war file on the web server (Like tomcat)
You build your Angular client application
.ts files will be translated to equivalent .js files
The build process create a 'dist' folder. The dist folder will have .js and .html files with angular tags and directives.
You deploy dist folder on a server where node.js is installed
You go to browser and ask for index.html file
Server sends all the files in the 'dist' folder to the client, up on initial request. We now have entire client app in the browser
For all the subsequent requests, the client app will make a webservcie call to spring app through Ajax requests
Javascript will use DOM to update the part of the page with new data.
For all this to work, browser must support angular directives and must also know how to render custom components
Please help me understand!
Via HttpCLient
Most front-end applications communicate with backend services over the
HTTP protocol. Modern browsers support two different APIs for making
HTTP requests: the XMLHttpRequest interface and the fetch() API.
The HttpClient in #angular/common/http offers a simplified client HTTP
API for Angular applications that rests on the XMLHttpRequest interface exposed by browsers.
In the example below, we are creating a post call, params for this post are the posted object, the url, and httpOptions(Headers, httpParms etc ...)
addHero (hero: Hero): Observable<Hero> {
return this.http.post<Hero>(this.heroesUrl, hero, httpOptions)
.pipe(
catchError(this.handleError('addHero', hero))
);
}
addHero (hero: Hero): Observable<Hero> {
return this.http.post<Hero>(this.heroesUrl, hero, httpOptions)
.pipe(
catchError(this.handleError('addHero', hero))
);
}
Just like when you post from Postman, you should configure your call with the right parameters.
You call should be in a Service that will be injected in application, module, or component.

How to check Global HTTP batch endpoint is called

I received an email saying that JSON-RPC and Global HTTP Batch serving endpoints being discontinued, and that my project on Google Cloud Platform is calling Global HTTP Batch endpoint.
When I check the API dashboard of the project, however, "Google Cloud Storage JSON API" shows no usage for the last 30 days.
Does that mean the project no longer calls this endpoint?
If not (= if there is still a chance that we call this endpoint), how can I see whether a change that I will make to eliminate the call does actually eliminate the call?
If you are using a client from Google to make your request you are no longer calling the Global HTTP Batch endpoint as they have been updated to use the new API specific Batch endpoint.
You can still use the dev tools from your browser to check the request url from your app.

Grafana plugin - CORS issue with REST API

I'm currently developing grafana plugin using Angular-1 and ES6, retrieving data from REST API and representing them in grafana. The problem is that as far as grafana plugin is working within the browser, it sends ajax calls to our REST API and they are blocked:
No 'Access-Control-Allow-Origin' header is present on the requested resource. The response had HTTP status code 401.
We were required to solve this issue without adding that header on the REST API side. One simple solution was to use corsproxy.
But I'm curios to know whether there is some other way to use REST API within grafana. If I set up some datasource to my plugin, will it work as a kind of backend or my calls to REST API will still be AJAX calls?

Caching dynamic REST content in Cherokee

I'm developing a backend server for a mobile app using Cherokee + PHP-FPM + MySQL. I'm providing a RESTful API using Luracast Restler 2.
How do you cache dynamic content so that, for example, once a client has requested a list of items through the REST API, this list (in JSON format) is cached for every other client request until the content validity is set to expire? A global cache mechanism for all clients?
Restler 3 final release will have server side caching support built in the framework itself. Currently you have to implement it on your own within the api method

Resources