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.

28 lines
691 B

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace Apewer.Web
  5. {
  6. internal class ApiMiddleware
  7. {
  8. internal Type Type;
  9. internal Action<ApiContext, Action> Callback;
  10. public ApiMiddleware(Type type)
  11. {
  12. if (!typeof(IApiMiddleware).IsAssignableFrom(type)) throw new NotImplementedException($"类型【{type.FullName}】未实现【{nameof(IApiMiddleware)}】。");
  13. Type = type;
  14. }
  15. public ApiMiddleware(Action<ApiContext, Action> callback)
  16. {
  17. if (callback == null) throw new ArgumentNullException(nameof(callback));
  18. Callback = callback;
  19. }
  20. }
  21. }