All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nepxion.discovery.console.rest.SentinelUpdateRestInvoker Maven / Gradle / Ivy

There is a newer version: 6.22.0
Show newest version
package com.nepxion.discovery.console.rest;

/**
 * 

Title: Nepxion Discovery

*

Description: Nepxion Discovery

*

Copyright: Copyright (c) 2017-2050

*

Company: Nepxion

* @author Haojun Ren * @version 1.0 */ import java.util.List; import org.apache.commons.lang3.StringUtils; import org.springframework.cloud.client.ServiceInstance; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.web.client.RestTemplate; public class SentinelUpdateRestInvoker extends AbstractRestInvoker { private String type; private String rule; public SentinelUpdateRestInvoker(List serviceInstances, RestTemplate restTemplate, String type, String rule) { super(serviceInstances, restTemplate); this.type = type.trim(); this.rule = rule; } @Override protected String getInfo() { return "Sentinel rules updated"; } @Override protected String getSuffixPath() { return getPrefixPath(type) + "/update-" + type + "-rules"; } @Override protected String doRest(String url) { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON_UTF8); HttpEntity entity = new HttpEntity(rule, headers); return restTemplate.postForEntity(url, entity, String.class).getBody(); } @Override protected void checkPermission(ServiceInstance serviceInstance) throws Exception { checkConfigRestControlPermission(serviceInstance); } private String getPrefixPath(String type) { return StringUtils.equals(type, "param-flow") ? "sentinel-param" : "sentinel-core"; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy