File tree Expand file tree Collapse file tree
backend/internal/core/badge/a2a Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,13 +8,17 @@ import (
88 "errors"
99 "io"
1010 "net/http"
11+ "regexp"
1112 "strings"
1213
1314 "github.com/outshift/identity-service/internal/pkg/httputil"
1415 "github.com/outshift/identity-service/pkg/log"
1516)
1617
17- const wellKnownUrlSuffix = "/.well-known/agent.json"
18+ const (
19+ wellKnownMatcher = `/.well-known/.*\.json$`
20+ wellKnownUrlSuffixV3 = "/.well-known/agent-card.json"
21+ )
1822
1923// The discoverClient interface defines the core methods for discovering a deployed A2A agent
2024type DiscoveryClient interface {
@@ -37,9 +41,10 @@ func (d *discoveryClient) Discover(
3741 ctx context.Context ,
3842 wellKnownUrl string ,
3943) (string , error ) {
40- // validate the well-known URL
41- if ! strings .HasSuffix (wellKnownUrl , wellKnownUrlSuffix ) {
42- wellKnownUrl = strings .TrimSuffix (wellKnownUrl , "/" ) + wellKnownUrlSuffix
44+ // Check if the well-known URL ends with .json, if not, append the default V3 suffix
45+ var wellKnownUrlRegex = regexp .MustCompile (wellKnownMatcher )
46+ if ! wellKnownUrlRegex .MatchString (wellKnownUrl ) {
47+ wellKnownUrl = strings .TrimSuffix (wellKnownUrl , "/" ) + wellKnownUrlSuffixV3
4348 }
4449
4550 log .Debug ("Using well-known URL for agent discovery: " , wellKnownUrl )
You can’t perform that action at this time.
0 commit comments