InterceptorsFiles returns the interceptors files for the given service.
(_ string, service *expr.ServiceExpr, services *ServicesData)
| 9 | |
| 10 | // InterceptorsFiles returns the interceptors files for the given service. |
| 11 | func InterceptorsFiles(_ string, service *expr.ServiceExpr, services *ServicesData) []*codegen.File { |
| 12 | var files []*codegen.File |
| 13 | svc := services.Get(service.Name) |
| 14 | |
| 15 | // Generate service-specific interceptor files |
| 16 | if len(svc.ServerInterceptors) > 0 { |
| 17 | files = append(files, interceptorFile(svc, true)) |
| 18 | } |
| 19 | if len(svc.ClientInterceptors) > 0 { |
| 20 | files = append(files, interceptorFile(svc, false)) |
| 21 | } |
| 22 | |
| 23 | // Generate wrapper file if this service has any interceptors |
| 24 | if len(svc.ServerInterceptors) > 0 || len(svc.ClientInterceptors) > 0 { |
| 25 | files = append(files, wrapperFile(svc)) |
| 26 | } |
| 27 | |
| 28 | return files |
| 29 | } |
| 30 | |
| 31 | // interceptorFile returns the file defining the interceptors. |
| 32 | // This method is called twice, once for the server and once for the client. |