ducky/devices
ducky/devices/vendor/bitbucket.org/ww/goautoneg/README.txt
Add endpoint for retrieving devices. Add an endpoint for retrieving devices, either as a list or by ID. Stub endpoints for updating and deleting devices., along with TODOs marking them as things to still be completed. (Right now, accessing those endpoints is an insta-panic.) Simplify our handleCreateDevices by returning StatusUnauthorized if AuthUser fails, so we can reserve StatusForbidden for when auth succeeds but access is still denied. Also, delay the instantiation and allocation of a Response variable until we're actually going to use it. Create a handleGetDevices handler that authenticates the user, and if no ID is set, returns a list of all their Devices. If one or more IDs are set, only those Devices are returned. If ScopeViewPushToken is one of the scopes associated with the request, the push tokens for each Device will be included in the response. Otherwise, they will be omitted.
| paddy@15 | 1 PACKAGE |
| paddy@15 | 2 |
| paddy@15 | 3 package goautoneg |
| paddy@15 | 4 import "bitbucket.org/ww/goautoneg" |
| paddy@15 | 5 |
| paddy@15 | 6 HTTP Content-Type Autonegotiation. |
| paddy@15 | 7 |
| paddy@15 | 8 The functions in this package implement the behaviour specified in |
| paddy@15 | 9 http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html |
| paddy@15 | 10 |
| paddy@15 | 11 Copyright (c) 2011, Open Knowledge Foundation Ltd. |
| paddy@15 | 12 All rights reserved. |
| paddy@15 | 13 |
| paddy@15 | 14 Redistribution and use in source and binary forms, with or without |
| paddy@15 | 15 modification, are permitted provided that the following conditions are |
| paddy@15 | 16 met: |
| paddy@15 | 17 |
| paddy@15 | 18 Redistributions of source code must retain the above copyright |
| paddy@15 | 19 notice, this list of conditions and the following disclaimer. |
| paddy@15 | 20 |
| paddy@15 | 21 Redistributions in binary form must reproduce the above copyright |
| paddy@15 | 22 notice, this list of conditions and the following disclaimer in |
| paddy@15 | 23 the documentation and/or other materials provided with the |
| paddy@15 | 24 distribution. |
| paddy@15 | 25 |
| paddy@15 | 26 Neither the name of the Open Knowledge Foundation Ltd. nor the |
| paddy@15 | 27 names of its contributors may be used to endorse or promote |
| paddy@15 | 28 products derived from this software without specific prior written |
| paddy@15 | 29 permission. |
| paddy@15 | 30 |
| paddy@15 | 31 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| paddy@15 | 32 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| paddy@15 | 33 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| paddy@15 | 34 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| paddy@15 | 35 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| paddy@15 | 36 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| paddy@15 | 37 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| paddy@15 | 38 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| paddy@15 | 39 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| paddy@15 | 40 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| paddy@15 | 41 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| paddy@15 | 42 |
| paddy@15 | 43 |
| paddy@15 | 44 FUNCTIONS |
| paddy@15 | 45 |
| paddy@15 | 46 func Negotiate(header string, alternatives []string) (content_type string) |
| paddy@15 | 47 Negotiate the most appropriate content_type given the accept header |
| paddy@15 | 48 and a list of alternatives. |
| paddy@15 | 49 |
| paddy@15 | 50 func ParseAccept(header string) (accept []Accept) |
| paddy@15 | 51 Parse an Accept Header string returning a sorted list |
| paddy@15 | 52 of clauses |
| paddy@15 | 53 |
| paddy@15 | 54 |
| paddy@15 | 55 TYPES |
| paddy@15 | 56 |
| paddy@15 | 57 type Accept struct { |
| paddy@15 | 58 Type, SubType string |
| paddy@15 | 59 Q float32 |
| paddy@15 | 60 Params map[string]string |
| paddy@15 | 61 } |
| paddy@15 | 62 Structure to represent a clause in an HTTP Accept Header |
| paddy@15 | 63 |
| paddy@15 | 64 |
| paddy@15 | 65 SUBDIRECTORIES |
| paddy@15 | 66 |
| paddy@15 | 67 .hg |