(method, path string)
| 333 | } |
| 334 | |
| 335 | func route(method, path string) *expr.RouteExpr { |
| 336 | r := &expr.RouteExpr{Method: method, Path: path} |
| 337 | |
| 338 | switch e := eval.Current().(type) { |
| 339 | case *expr.HTTPServiceExpr: |
| 340 | // Service-level route - only allowed for JSON-RPC services |
| 341 | if e.ServiceExpr.Meta == nil || e.ServiceExpr.Meta["jsonrpc:service"] == nil { |
| 342 | eval.ReportError("routes at the service level are only allowed for JSON-RPC services. Use method-level routes instead.") |
| 343 | return r |
| 344 | } |
| 345 | // For JSON-RPC services, store the route in the service |
| 346 | e.JSONRPCRoute = r |
| 347 | return r |
| 348 | |
| 349 | case *expr.HTTPEndpointExpr: |
| 350 | // Method-level route - not allowed for JSON-RPC endpoints |
| 351 | if e.IsJSONRPC() { |
| 352 | eval.ReportError("JSON-RPC endpoints cannot define routes at the method level. Define routes at the service level using JSONRPC(func() { GET(\"/path\") })") |
| 353 | return r |
| 354 | } |
| 355 | r.Endpoint = e |
| 356 | e.Routes = append(e.Routes, r) |
| 357 | return r |
| 358 | |
| 359 | default: |
| 360 | eval.IncompatibleDSL() |
| 361 | return r |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | // Header describes a single HTTP header or gRPC metadata header. The properties |
| 366 | // (description, type, validation etc.) of a header are inherited from the |
no test coverage detected