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.
 
 
 
 
 
 

39 lines
1.4 KiB

  1. using Nancy;
  2. using Nancy.Bootstrapper;
  3. using Nancy.TinyIoc;
  4. namespace Learun.Application.WorkFlowServer
  5. {
  6. /// <summary>
  7. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  8. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  9. /// 创建人:陈彬彬
  10. /// 日 期:2017.05.12
  11. /// 描 述:Nancy-初始化
  12. /// </summary>
  13. public class Bootstraper : DefaultNancyBootstrapper
  14. {
  15. /// <summary>
  16. /// 自定义请求启动函数
  17. /// </summary>
  18. /// <param name="container"></param>
  19. /// <param name="pipelines"></param>
  20. /// <param name="context"></param>
  21. protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context)
  22. {
  23. //CORS Enable
  24. pipelines.AfterRequest.AddItemToEndOfPipeline((ctx) =>
  25. {
  26. var originlist = ctx.Request.Headers["Origin"];
  27. foreach (var origin in originlist)
  28. {
  29. ctx.Response.WithHeader("Access-Control-Allow-Origin", origin);
  30. }
  31. ctx.Response.WithHeader("Access-Control-Allow-Methods", "POST,GET")
  32. .WithHeader("Access-Control-Allow-Credentials", "true")
  33. .WithHeader("Access-Control-Allow-Headers", "Accept, Origin, Content-type");
  34. });
  35. }
  36. }
  37. }