Update on the review comments

This commit is contained in:
MohitKatare-protean
2025-03-31 22:40:59 +05:30
parent f0e39e34e7
commit bbb1dbc843
9 changed files with 139 additions and 129 deletions

View File

@@ -201,11 +201,6 @@ func validateRules(rules []routingRule) error {
// Route determines the routing destination based on the request context.
func (r *Router) Route(ctx context.Context, url *url.URL, body []byte) (*model.Route, error) {
if r == nil {
log.Debug(ctx, "In Router :Router not set")
}
log.Debugf(ctx, "In Router: Routing request with url %v and body: %s", url, string(body))
// Parse the body to extract domain and version
var requestBody struct {
Context struct {
@@ -218,17 +213,11 @@ func (r *Router) Route(ctx context.Context, url *url.URL, body []byte) (*model.R
if err := json.Unmarshal(body, &requestBody); err != nil {
return nil, fmt.Errorf("error parsing request body: %w", err)
}
log.Debugf(ctx, "In Router: Routing request with %v and body: %#s", url, requestBody)
log.Debugf(ctx, "In Router: Routing request with %v and body: %v", url, requestBody)
// Extract the endpoint from the URL
endpoint := path.Base(url.Path)
if r.rules == nil {
log.Debug(ctx, "In Router :Routing rules not set")
}
log.Debugf(ctx, "In Router :Routing rules len :%d", len(r.rules))
// Lookup route in the optimized map
domainRules, ok := r.rules[requestBody.Context.Domain]
if !ok {