()
| 557 | } |
| 558 | |
| 559 | func (s *Server) AddCorsOption() { |
| 560 | newDir := &Directive{ |
| 561 | Name: "if", |
| 562 | Parameters: []string{"(", "$request_method", "=", "'OPTIONS'", ")"}, |
| 563 | Block: &Block{}, |
| 564 | } |
| 565 | block := &Block{} |
| 566 | block.AppendDirectives(&Directive{ |
| 567 | Name: "return", |
| 568 | Parameters: []string{"204"}, |
| 569 | }) |
| 570 | newDir.Block = block |
| 571 | directives := s.GetDirectives() |
| 572 | newDirectives := make([]IDirective, 0) |
| 573 | for _, dir := range directives { |
| 574 | if dir.GetName() != "listen" { |
| 575 | newDirectives = append(newDirectives, dir) |
| 576 | } |
| 577 | } |
| 578 | newDirectives = append(newDirectives, newDir) |
| 579 | s.Directives = newDirectives |
| 580 | } |
no test coverage detected