(opts []interface{})
| 569 | } |
| 570 | |
| 571 | func newServerOpts(opts []interface{}) *twirp.ServerOptions { |
| 572 | serverOpts := &twirp.ServerOptions{} |
| 573 | for _, opt := range opts { |
| 574 | switch o := opt.(type) { |
| 575 | case twirp.ServerOption: |
| 576 | o(serverOpts) |
| 577 | case *twirp.ServerHooks: // backwards compatibility, allow to specify hooks as an argument |
| 578 | twirp.WithServerHooks(o)(serverOpts) |
| 579 | case nil: // backwards compatibility, allow nil value for the argument |
| 580 | continue |
| 581 | default: |
| 582 | panic(fmt.Sprintf("Invalid option type %T, please use a twirp.ServerOption", o)) |
| 583 | } |
| 584 | } |
| 585 | return serverOpts |
| 586 | } |
| 587 | |
| 588 | // WriteError writes an HTTP response with a valid Twirp error format (code, msg, meta). |
| 589 | // Useful outside of the Twirp server (e.g. http middleware), but does not trigger hooks. |
no outgoing calls
no test coverage detected