MCPcopy Index your code
hub / github.com/Permify/permify / loadFromURL

Function loadFromURL

pkg/schema/loader.go:84–107  ·  view source on GitHub ↗

End isFilePath

(inputURL string)

Source from the content-addressed store, hash-verified

82 return true, nil // File exists
83} // End isFilePath
84func loadFromURL(inputURL string) (string, error) { // Load schema from URL
85 // Parse and validate the URL
86 parsedURL, err := url.Parse(inputURL)
87 if err != nil {
88 return "", err
89 }
90 // Add checks here to validate the scheme, host, etc., of parsedURL
91 // For example, ensure the scheme is either http or https
92 if parsedURL.Scheme != "http" && parsedURL.Scheme != "https" {
93 return "", errors.New("invalid URL scheme")
94 }
95 // Perform the HTTP GET request
96 resp, err := http.Get(parsedURL.String())
97 if err != nil { // HTTP request failed
98 return "", err // Return error
99 } // Request succeeded
100 defer resp.Body.Close() // Ensure cleanup
101 // Read the response body
102 body, err := io.ReadAll(resp.Body) // Read response
103 if err != nil { // Read failed
104 return "", err // Return error
105 } // Read succeeded
106 return string(body), nil // Return body
107} // End loadFromURL
108func loadFromFile(path string) (string, error) { // Load schema from file
109 // Clean the path
110 cleanPath := filepath.Clean(path)

Callers 1

loader_test.goFile · 0.85

Calls 4

ParseMethod · 0.80
GetMethod · 0.65
StringMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected