api.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright (c) 2012-2013 Jason McVetta. This is Free Software, released
  2. // under the terms of the GPL v3. See http://www.gnu.org/copyleft/gpl.html for
  3. // details. Resist intellectual serfdom - the ownership of ideas is akin to
  4. // slavery.
  5. package napping
  6. /*
  7. This module implements the Napping API.
  8. */
  9. import (
  10. "net/url"
  11. )
  12. // Send composes and sends and HTTP request.
  13. func Send(r *Request) (*Response, error) {
  14. s := Session{}
  15. return s.Send(r)
  16. }
  17. // Get sends a GET request.
  18. func Get(url string, p *url.Values, result, errMsg interface{}) (*Response, error) {
  19. s := Session{}
  20. return s.Get(url, p, result, errMsg)
  21. }
  22. // Options sends an OPTIONS request.
  23. func Options(url string, result, errMsg interface{}) (*Response, error) {
  24. s := Session{}
  25. return s.Options(url, result, errMsg)
  26. }
  27. // Head sends a HEAD request.
  28. func Head(url string, result, errMsg interface{}) (*Response, error) {
  29. s := Session{}
  30. return s.Head(url, result, errMsg)
  31. }
  32. // Post sends a POST request.
  33. func Post(url string, payload, result, errMsg interface{}) (*Response, error) {
  34. s := Session{}
  35. return s.Post(url, payload, result, errMsg)
  36. }
  37. // Put sends a PUT request.
  38. func Put(url string, payload, result, errMsg interface{}) (*Response, error) {
  39. s := Session{}
  40. return s.Put(url, payload, result, errMsg)
  41. }
  42. // Patch sends a PATCH request.
  43. func Patch(url string, payload, result, errMsg interface{}) (*Response, error) {
  44. s := Session{}
  45. return s.Patch(url, payload, result, errMsg)
  46. }
  47. // Delete sends a DELETE request.
  48. func Delete(url string, p *url.Values, result, errMsg interface{}) (*Response, error) {
  49. s := Session{}
  50. return s.Delete(url, p, result, errMsg)
  51. }