MCPcopy Create free account
hub / github.com/goadesign/goa / route

Function route

dsl/http.go:335–363  ·  view source on GitHub ↗
(method, path string)

Source from the content-addressed store, hash-verified

333}
334
335func 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

Callers 9

GETFunction · 0.85
HEADFunction · 0.85
POSTFunction · 0.85
PUTFunction · 0.85
DELETEFunction · 0.85
OPTIONSFunction · 0.85
TRACEFunction · 0.85
CONNECTFunction · 0.85
PATCHFunction · 0.85

Calls 4

CurrentFunction · 0.92
ReportErrorFunction · 0.92
IncompatibleDSLFunction · 0.92
IsJSONRPCMethod · 0.80

Tested by

no test coverage detected