seninel部署
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

12345678910111213141516171819202122232425262728293031323334353637
  1. # Sentinel Web Servlet Filter
  2. Sentinel provides Servlet filter integration to enable flow control for web requests. Add the following dependency in `pom.xml` (if you are using Maven):
  3. ```xml
  4. <dependency>
  5. <groupId>com.alibaba.csp</groupId>
  6. <artifactId>sentinel-web-servlet</artifactId>
  7. <version>x.y.z</version>
  8. </dependency>
  9. ```
  10. To use the filter, you can simply configure your `web.xml` with:
  11. ```xml
  12. <filter>
  13. <filter-name>SentinelCommonFilter</filter-name>
  14. <filter-class>com.alibaba.csp.sentinel.adapter.servlet.CommonFilter</filter-class>
  15. </filter>
  16. <filter-mapping>
  17. <filter-name>SentinelCommonFilter</filter-name>
  18. <url-pattern>/*</url-pattern>
  19. </filter-mapping>
  20. ```
  21. When a request is blocked, Sentinel servlet filter will give a default page indicating the request blocked.
  22. If customized block page is set (via `WebServletConfig.setBlockPage(blockPage)` method),
  23. the filter will redirect the request to provided URL. You can also implement your own
  24. block handler (the `UrlBlockHandler` interface) and register to `WebCallbackManager`.
  25. The `UrlCleaner` interface is designed for clean and unify the URL resource.
  26. For REST APIs, you have to clean the URL resource (e.g. `/foo/1` and `/foo/2` -> `/foo/:id`), or
  27. the amount of context and resources will exceed the threshold.
  28. `RequestOriginParser` interface is useful for extracting request origin (e.g. IP or appName from HTTP Header)
  29. from HTTP request. You can implement your own `RequestOriginParser` and register to `WebCallbackManager`.