class EndpointOptimizer

Overview

Endpoint optimization module that handles endpoint deduplication, URL combination, and path parameter extraction

Direct Known Subclasses

Defined in:

optimizer/optimizer.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(logger : NoirLogger, options : Hash(String, YAML::Any)) #

[View source]

Instance Method Detail

def add_path_parameters(endpoints : Array(Endpoint)) : Array(Endpoint) #

Add path parameters by parsing URL patterns


[View source]
def apply_pvalue(param_type, param_name, param_value) : String #

Apply parameter values based on configuration


[View source]
def combine_url_and_endpoints(endpoints : Array(Endpoint)) : Array(Endpoint) #

Combine target URL with endpoints


[View source]
def normalize_url_shapes(endpoints : Array(Endpoint)) : Array(Endpoint) #

Normalize cross-framework URL shapes the analyzers can't always resolve without language context. Rewrites a small set of well- known leaky forms into the canonical {name} placeholder so the downstream #add_path_parameters pass picks them up as path params instead of literal noise.

Covered shapes:

  • (?P<name>pattern) — Python re_path-style named groups. Bleeds through Django's re_path route table; rewrite to {name} and drop the regex body.
  • ${name} / ${obj.field} — JS/TS template literals that analyzers can't statically resolve (handler files reference captured variables, not literal paths). Rewrite to {name} (or {field} for ${obj.field}) so the AI/output payload surfaces it as a path placeholder rather than as a literal ${...} segment.
  • Python regex anchors ^ (leading) and $/\Z (trailing) — re_path patterns commonly include these.
  • Python regex backslash-escaped dots \. — rewrite to plain . for the visible URL.
  • Spring {name:regex} — strip the inline regex constraint so the placeholder is {name} regardless of framework dialect.

[View source]
def optimize(endpoints : Array(Endpoint)) : Array(Endpoint) #

Main optimization workflow - calls all optimization steps


[View source]
def optimize_endpoints(endpoints : Array(Endpoint)) : Array(Endpoint) #

Remove duplicated endpoints and parameters, validate HTTP methods, clean URLs


[View source]