简体   繁体   English

ff4j客户端如何使用ff4j服务器(spring mvc)暴露的rest api?

[英]How can ff4j client consume the rest api exposed by ff4j server(spring mvc)?

I have used ff4j-sample-springboot2x-jdbc-postgres and setup my ff4j server along with DB part and exposed the api - accessible at "/api/ff4j".我使用了 ff4j-sample-springboot2x-jdbc-postgres并设置了我的 ff4j 服务器以及 DB 部分,并暴露了 api - 可在“/api/ff4j”访问。 This is my admin component.这是我的管理组件。

Now I want a client microservice (also a springboot app) to consume this REST api and use ff4j.check() and other methods.现在我想要一个客户端微服务(也是一个 springboot 应用程序)来使用这个 REST api 并使用 ff4j.check() 和其他方法。 Is there a quick way ( less code - I need to do this for many apps ) to consume the api on client-side?有没有一种快速的方法(更少的代码 - 我需要为许多应用程序执行此操作)在客户端使用 api?

PS .附言 - For the server I have simply used a DB and ff4j-spring-starter(just like in the sample) - I have not used and jersey/jetty dependencies -对于服务器,我只使用了 DB 和 ff4j-spring-starter(就像在示例中一样) - 我没有使用和 jersey/jetty 依赖项

The client accesses the FF4j service using its own FF4j object.客户端使用自己的 FF4j object 访问 FF4j 服务。

When you create a FF4j object, you define the FeatureStore and PropertyStore that it uses, which determines how the store is accessed.当您创建 FF4j object 时,您定义了它使用的 FeatureStore 和 PropertyStore,这决定了如何访问存储。 In your case, you want to use a FeatureStoreHttp and PropertyStoreHttp.在您的情况下,您想使用 FeatureStoreHttp 和 PropertyStoreHttp。

String ff4jApiEndPoint = "https://my-ff4j-service.org/api/ff4j";
FeatureStoreHttp  fStore = new FeatureStoreHttp(ff4jApiEndPoint);
PropertyStoreHttp pStore = new PropertyStoreHttp(ff4jApiEndPoint);    
FF4j client_ff4j = new FF4j(fStore, pStore);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM