README.txt 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. PACKAGE
  2. package goautoneg
  3. import "bitbucket.org/ww/goautoneg"
  4. HTTP Content-Type Autonegotiation.
  5. The functions in this package implement the behaviour specified in
  6. http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
  7. Copyright (c) 2011, Open Knowledge Foundation Ltd.
  8. All rights reserved.
  9. Redistribution and use in source and binary forms, with or without
  10. modification, are permitted provided that the following conditions are
  11. met:
  12. Redistributions of source code must retain the above copyright
  13. notice, this list of conditions and the following disclaimer.
  14. Redistributions in binary form must reproduce the above copyright
  15. notice, this list of conditions and the following disclaimer in
  16. the documentation and/or other materials provided with the
  17. distribution.
  18. Neither the name of the Open Knowledge Foundation Ltd. nor the
  19. names of its contributors may be used to endorse or promote
  20. products derived from this software without specific prior written
  21. permission.
  22. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  25. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  26. HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  27. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  28. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  29. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  30. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  32. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. FUNCTIONS
  34. func Negotiate(header string, alternatives []string) (content_type string)
  35. Negotiate the most appropriate content_type given the accept header
  36. and a list of alternatives.
  37. func ParseAccept(header string) (accept []Accept)
  38. Parse an Accept Header string returning a sorted list
  39. of clauses
  40. TYPES
  41. type Accept struct {
  42. Type, SubType string
  43. Q float32
  44. Params map[string]string
  45. }
  46. Structure to represent a clause in an HTTP Accept Header
  47. SUBDIRECTORIES
  48. .hg