raw.go 749 B

123456789101112131415161718192021222324
  1. package api
  2. // Raw can be used to do raw queries against custom endpoints
  3. type Raw struct {
  4. c *Client
  5. }
  6. // Raw returns a handle to query endpoints
  7. func (c *Client) Raw() *Raw {
  8. return &Raw{c}
  9. }
  10. // Query is used to do a GET request against an endpoint
  11. // and deserialize the response into an interface using
  12. // standard Consul conventions.
  13. func (raw *Raw) Query(endpoint string, out interface{}, q *QueryOptions) (*QueryMeta, error) {
  14. return raw.c.query(endpoint, out, q)
  15. }
  16. // Write is used to do a PUT request against an endpoint
  17. // and serialize/deserialized using the standard Consul conventions.
  18. func (raw *Raw) Write(endpoint string, in, out interface{}, q *WriteOptions) (*WriteMeta, error) {
  19. return raw.c.write(endpoint, in, out, q)
  20. }