You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dashboard.md 1.9 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # Dashboard
  2. The CAP provides a Dashboard for viewing messages, and the features provided by Dashboard make it easy to view and manage messages.
  3. ## Enable Dashboard
  4. By default, Dashboard middleware will not be launched. To enable Dashboard functionality you need to add the following code to your configuration:
  5. ```C#
  6. services.AddCap(x =>
  7. {
  8. //...
  9. // Register Dashboard
  10. x.UseDashboard();
  11. });
  12. ```
  13. By default, you can open the Dashboard by visiting the url `http://localhost:xxx/cap`.
  14. ### Dashboard Configuration
  15. * PathMatch
  16. > Default :'/cap'
  17. You can change the path of the Dashboard by modifying this configuration item.
  18. * StatsPollingInterval
  19. > Default: 2000ms
  20. This configuration item is used to configure the Dashboard front end to get the polling time of the status interface (/stats).
  21. * Authorization
  22. This configuration item is used to configure the authorization filter when accessing the Dashboard. The default filter allows LAN access. When your application wants to provide external network access, you can customize the authentication rules by setting this configuration. See the next section for details.
  23. ### Custom authentication
  24. Dashboard authentication can be customized by implementing the `IDashboardAuthorizationFilter` interface.
  25. The following is a sample code that determines if access is allowed by reading the accesskey from the url request parameter.
  26. ```C#
  27. public class TestAuthorizationFilter : IDashboardAuthorizationFilter
  28. {
  29. public bool Authorize(DashboardContext context)
  30. {
  31. if(context.Request.GetQuery("accesskey")=="xxxxxx"){
  32. return true;
  33. }
  34. return false;
  35. }
  36. }
  37. ```
  38. Then configure this filter when registration Dashboard.
  39. ```C#
  40. services.AddCap(x =>
  41. {
  42. //...
  43. // Register Dashboard
  44. x.UseDashboard(opt => {
  45. opt.Authorization = new[] {new TestAuthorizationFilter()};
  46. });
  47. });
  48. ```