2024-09-19 07:57:26 +00:00
|
|
|
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
|
|
|
|
|
|
|
|
package folio
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/url"
|
|
|
|
"decl/internal/data"
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
)
|
|
|
|
|
|
|
|
/* Create a new resource using a parsed URI */
|
|
|
|
func NewResourceFromParsedURI(u *url.URL, document data.Document) (newResource data.Resource, err error) {
|
|
|
|
if document == nil {
|
|
|
|
declaration := NewDeclaration()
|
2024-10-16 17:26:42 +00:00
|
|
|
if err = declaration.NewResourceFromParsedURI((*ParsedURI)(u)); err == nil {
|
2024-09-19 07:57:26 +00:00
|
|
|
return declaration.Attributes, err
|
|
|
|
}
|
|
|
|
} else {
|
2024-10-16 17:26:42 +00:00
|
|
|
newResource, err = document.NewResourceFromParsedURI((*ParsedURI)(u))
|
2024-09-19 07:57:26 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|