@@ -8,47 +8,47 @@ type ResourceOption func(*Resource)
8
8
// The resource will be configured based on the provided options.
9
9
// Options are applied in order, allowing for flexible resource configuration.
10
10
func NewResource (uri string , name string , opts ... ResourceOption ) Resource {
11
- resource := Resource {
12
- URI : uri ,
13
- Name : name ,
14
- }
11
+ resource := Resource {
12
+ URI : uri ,
13
+ Name : name ,
14
+ }
15
15
16
- for _ , opt := range opts {
17
- opt (& resource )
18
- }
16
+ for _ , opt := range opts {
17
+ opt (& resource )
18
+ }
19
19
20
- return resource
20
+ return resource
21
21
}
22
22
23
23
// WithResourceDescription adds a description to the Resource.
24
24
// The description should provide a clear, human-readable explanation of what the resource represents.
25
25
func WithResourceDescription (description string ) ResourceOption {
26
- return func (r * Resource ) {
27
- r .Description = description
28
- }
26
+ return func (r * Resource ) {
27
+ r .Description = description
28
+ }
29
29
}
30
30
31
31
// WithMIMEType sets the MIME type for the Resource.
32
32
// This should indicate the format of the resource's contents.
33
33
func WithMIMEType (mimeType string ) ResourceOption {
34
- return func (r * Resource ) {
35
- r .MIMEType = mimeType
36
- }
34
+ return func (r * Resource ) {
35
+ r .MIMEType = mimeType
36
+ }
37
37
}
38
38
39
39
// WithAnnotations adds annotations to the Resource.
40
40
// Annotations can provide additional metadata about the resource's intended use.
41
41
func WithAnnotations (audience []Role , priority float64 ) ResourceOption {
42
- return func (r * Resource ) {
43
- if r .Annotations == nil {
44
- r .Annotations = & struct {
45
- Audience []Role `json:"audience,omitempty"`
46
- Priority float64 `json:"priority,omitempty"`
47
- }{}
48
- }
49
- r .Annotations .Audience = audience
50
- r .Annotations .Priority = priority
51
- }
42
+ return func (r * Resource ) {
43
+ if r .Annotations == nil {
44
+ r .Annotations = & struct {
45
+ Audience []Role `json:"audience,omitempty"`
46
+ Priority float64 `json:"priority,omitempty"`
47
+ }{}
48
+ }
49
+ r .Annotations .Audience = audience
50
+ r .Annotations .Priority = priority
51
+ }
52
52
}
53
53
54
54
// ResourceTemplateOption is a function that configures a ResourceTemplate.
@@ -59,45 +59,45 @@ type ResourceTemplateOption func(*ResourceTemplate)
59
59
// The template will be configured based on the provided options.
60
60
// Options are applied in order, allowing for flexible template configuration.
61
61
func NewResourceTemplate (uriTemplate string , name string , opts ... ResourceTemplateOption ) ResourceTemplate {
62
- template := ResourceTemplate {
63
- URITemplate : uriTemplate ,
64
- Name : name ,
65
- }
62
+ template := ResourceTemplate {
63
+ URITemplate : uriTemplate ,
64
+ Name : name ,
65
+ }
66
66
67
- for _ , opt := range opts {
68
- opt (& template )
69
- }
67
+ for _ , opt := range opts {
68
+ opt (& template )
69
+ }
70
70
71
- return template
71
+ return template
72
72
}
73
73
74
74
// WithTemplateDescription adds a description to the ResourceTemplate.
75
75
// The description should provide a clear, human-readable explanation of what resources this template represents.
76
76
func WithTemplateDescription (description string ) ResourceTemplateOption {
77
- return func (t * ResourceTemplate ) {
78
- t .Description = description
79
- }
77
+ return func (t * ResourceTemplate ) {
78
+ t .Description = description
79
+ }
80
80
}
81
81
82
82
// WithTemplateMIMEType sets the MIME type for the ResourceTemplate.
83
83
// This should only be set if all resources matching this template will have the same type.
84
84
func WithTemplateMIMEType (mimeType string ) ResourceTemplateOption {
85
- return func (t * ResourceTemplate ) {
86
- t .MIMEType = mimeType
87
- }
85
+ return func (t * ResourceTemplate ) {
86
+ t .MIMEType = mimeType
87
+ }
88
88
}
89
89
90
90
// WithTemplateAnnotations adds annotations to the ResourceTemplate.
91
91
// Annotations can provide additional metadata about the template's intended use.
92
92
func WithTemplateAnnotations (audience []Role , priority float64 ) ResourceTemplateOption {
93
- return func (t * ResourceTemplate ) {
94
- if t .Annotations == nil {
95
- t .Annotations = & struct {
96
- Audience []Role `json:"audience,omitempty"`
97
- Priority float64 `json:"priority,omitempty"`
98
- }{}
99
- }
100
- t .Annotations .Audience = audience
101
- t .Annotations .Priority = priority
102
- }
93
+ return func (t * ResourceTemplate ) {
94
+ if t .Annotations == nil {
95
+ t .Annotations = & struct {
96
+ Audience []Role `json:"audience,omitempty"`
97
+ Priority float64 `json:"priority,omitempty"`
98
+ }{}
99
+ }
100
+ t .Annotations .Audience = audience
101
+ t .Annotations .Priority = priority
102
+ }
103
103
}
0 commit comments