Module: Datadog::AppSec::APISecurity::EndpointCollection::RailsRouteSerializer

Defined in:
lib/datadog/appsec/api_security/endpoint_collection/rails_route_serializer.rb

Overview

This module serializes Rails Journey Router routes.

Constant Summary collapse

FORMAT_SUFFIX =
"(.:format)"

Class Method Summary collapse

Class Method Details

.serialize(route) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/datadog/appsec/api_security/endpoint_collection/rails_route_serializer.rb', line 13

def serialize(route)
  method = route.verb.empty? ? "*" : route.verb
  path = route.path.spec.to_s.delete_suffix(FORMAT_SUFFIX)

  {
    type: "REST",
    resource_name: "#{method} #{path}",
    operation_name: "http.request",
    method: method,
    path: path
  }
end