diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2018-02-07 19:33:36 +0100 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2018-02-07 19:33:36 +0100 |
| commit | 801b5207dcbf3438e7612e1f7edc9de32ce0780c (patch) | |
| tree | 6f0454ec49bf769e361cfa393290efc68583ca67 /container.go | |
| parent | 8bddda344201d9f034b5e9c2e9c37a25caeb80cb (diff) | |
| download | go-schwift-801b5207dcbf3438e7612e1f7edc9de32ce0780c.tar.gz | |
switch from reflection to code generation
This allows me to make the API much simpler. More simplification
forthcoming in the following commit; I just want to make a cut since
`make test` is happy right now.
Diffstat (limited to 'container.go')
| -rw-r--r-- | container.go | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/container.go b/container.go index cfc0eab..accae8e 100644 --- a/container.go +++ b/container.go @@ -79,8 +79,7 @@ func (c *Container) Headers() (ContainerHeaders, error) { return ContainerHeaders{}, err } - headers := NewContainerHeaders() - headers.FromHTTP(resp.Header) + headers := ContainerHeaders(headersFromHTTP(resp.Header)) err = headers.Validate() if err != nil { return headers, err @@ -96,11 +95,10 @@ func (c *Container) Headers() (ContainerHeaders, error) { // //A successful POST request implies Invalidate() since it may change metadata. func (c *Container) Update(headers ContainerHeaders, opts *RequestOptions) error { - ensureInitializedByReflection(headers) _, err := Request{ Method: "POST", ContainerName: c.name, - Headers: headers.ToHTTP(), + Headers: headersToHTTP(headers), Options: opts, ExpectStatusCodes: []int{204}, }.Do(c.a.client) @@ -117,11 +115,10 @@ func (c *Container) Update(headers ContainerHeaders, opts *RequestOptions) error // //A successful PUT request implies Invalidate() since it may change metadata. func (c *Container) Create(headers ContainerHeaders, opts *RequestOptions) error { - ensureInitializedByReflection(headers) _, err := Request{ Method: "PUT", ContainerName: c.name, - Headers: headers.ToHTTP(), + Headers: headersToHTTP(headers), Options: opts, ExpectStatusCodes: []int{201, 202}, }.Do(c.a.client) @@ -139,18 +136,11 @@ func (c *Container) Create(headers ContainerHeaders, opts *RequestOptions) error //This operation fails with http.StatusNotFound if the container does not exist. // //A successful DELETE request implies Invalidate(). -func (c *Container) Delete(headers *ContainerHeaders, opts *RequestOptions) error { - if headers == nil { - h := NewContainerHeaders() - headers = &h - } else { - ensureInitializedByReflection(*headers) - } - +func (c *Container) Delete(headers ContainerHeaders, opts *RequestOptions) error { _, err := Request{ Method: "DELETE", ContainerName: c.name, - Headers: headers.ToHTTP(), + Headers: headersToHTTP(headers), Options: opts, ExpectStatusCodes: []int{204}, }.Do(c.a.client) |
