diff options
Diffstat (limited to 'generated.go.in')
| -rw-r--r-- | generated.go.in | 50 |
1 files changed, 8 insertions, 42 deletions
diff --git a/generated.go.in b/generated.go.in index 85c257a..2858bcb 100644 --- a/generated.go.in +++ b/generated.go.in @@ -57,54 +57,20 @@ package schwift -import "net/textproto" - {{- range $htype, $hmeta := . }} //{{$htype}}Headers contains the headers for a schwift.{{$htype}} instance. // //To read and write well-known headers, use the methods on this type. -//To read and write arbitary headers, use the http.Header-like methods Get(), -//Set(), Clear(), Del(). -type {{$htype}}Headers map[string]string - -//Clear sets the value for the specified header to the empty string. When the -//Headers instance is then sent to the server with Update(), the server will -//delete the value for that header; cf. Del(). -func (h {{$htype}}Headers) Clear(key string) { - h[textproto.CanonicalMIMEHeaderKey(key)] = "" -} -{{/* */}} -{{- if eq $htype "Object" }} -//Del deletes a key from the Headers instance. When the Headers instance -//is then sent to the server with Update(), Del() has different effects -//depending on context because of Swift's inconsistent API: -// -//For most writable attributes, a key which has been deleted with Del() will -//remain unchanged on the server. To remove the key on the server, use Clear() -//instead. -// -//For object metadata (but not other object attributes), deleting a key will -//cause that key to be deleted on the server. Del() is identical to Clear() in -//this case. -{{- else }} -//Del deletes a key from the Headers instance. When the Headers instance is -//then sent to the server with Update(), a key which has been deleted with -//Del() will remain unchanged on the server. -{{- end }} -func (h {{$htype}}Headers) Del(key string) { - delete(h, textproto.CanonicalMIMEHeaderKey(key)) -} - -//Get returns the value for the specified header. -func (h {{$htype}}Headers) Get(key string) string { - return h[textproto.CanonicalMIMEHeaderKey(key)] +//To read and write arbitary headers, use the methods on the Headers supertype. +type {{$htype}}Headers struct { + Headers } -//Set sets a new value for the specified header. Any existing value will be -//overwritten. -func (h {{$htype}}Headers) Set(key, value string) { - h[textproto.CanonicalMIMEHeaderKey(key)] = value +//New{{$htype}}Headers creates a new {{$htype}}Headers instance. The return value +//will have the Headers attribute initialized to a non-nil map. +func New{{$htype}}Headers() {{$htype}}Headers { + return {{$htype}}Headers{make(Headers)} } //Validate returns MalformedHeaderError if the value of any well-known header @@ -125,7 +91,7 @@ func (h {{$htype}}Headers) Validate() error { //{{$field.Attribute}} provides type-safe access to {{$field.Header}} headers. func (h {{$htype}}Headers) {{$field.Attribute}}() Field{{$field.Type}} { - return Field{{$field.Type}}{h, "{{$field.Header}}"} + return Field{{$field.Type}}{h.Headers, "{{$field.Header}}"} } {{- end }} {{- end }} |
