-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I overwrite the metadata url? #84
Comments
I had to do similar, this is what I ended up with. I'm using Angular, so this may not apply for you. All AjaxAdapter have requestInterceptor, so you can do this for non-angular as well. import { HttpRequest } from "@angular/common/http";
import { AjaxRequestInterceptor } from "breeze-client";
import { AjaxHttpClientAdapter } from "breeze-client/adapter-ajax-httpclient";
import { AjaxRequest } from "breeze-client/src/interface-registry";
const metadataCacheBustRequestInterceptor: AjaxRequestInterceptor = Object.assign(
// AjaxRequest interface does not include the "request" param, it's added by AjaxHttpClientAdapter
(req: AjaxRequest & { request: HttpRequest<null> }) => {
// add a cache-busting query param for metadata
if (req.request.url.endsWith("/Metadata")) {
const params = req.request.params.set("v", "version string goes here!!!!!!!!!!");
req.request = req.request.clone({ params });
}
},
// will only run on the first request (i.e. Metadata)
{ oneTime: true },
);
// other breeze initialisation etc... goes here
// httpclient is an instance of angular HttpClient
const ajaxAdapter = AjaxHttpClientAdapter.register(httpClient);
ajaxAdapter.requestInterceptor = metadataCacheBustRequestInterceptor; |
One approach I used when I implemented a POS system that needed to work fully offline was to cache the metadata (along with data) in indexed db and when I needed to load the metadata, i used the MetadataStore.importMetadata. |
Hi,
To cache the metadata in the browser, I want to be able to add a version number to the metadata url. What is the best way to overwrite the default metadata url? It defaults to the service name property. I am aware of the technique of generating metadata at compile time/start up time and writing it to a file. I'd rather not do that.
The text was updated successfully, but these errors were encountered: