(ctx context.Context, uri string)
| 63 | } |
| 64 | |
| 65 | func ParseURIAndReplaceCurrentHost(ctx context.Context, uri string) (*Connection, error) { |
| 66 | conn, err := ParseURI(uri) |
| 67 | if err != nil { |
| 68 | return nil, fmt.Errorf("error parsing connection: %v", err) |
| 69 | } |
| 70 | if conn.Host == ConnHostCurrent { |
| 71 | source, err := GetConnNameFromContext(ctx) |
| 72 | if err != nil { |
| 73 | return nil, fmt.Errorf("error getting connection name from context: %v", err) |
| 74 | } |
| 75 | |
| 76 | // RPC context connection is empty for local connections |
| 77 | if source == "" { |
| 78 | source = wshrpc.LocalConnName |
| 79 | } |
| 80 | conn.Host = source |
| 81 | } |
| 82 | return conn, nil |
| 83 | } |
| 84 | |
| 85 | func GetConnNameFromContext(ctx context.Context) (string, error) { |
| 86 | handler := wshutil.GetRpcResponseHandlerFromContext(ctx) |
no test coverage detected