1package kivik
2
3const (
4	// KivikVersion is the version of the Kivik library.
5	KivikVersion = "1.0.0-beta"
6	// KivikVendor is the vendor string reported by this library.
7	KivikVendor = "Kivik"
8)
9
10// SessionCookieName is the name of the CouchDB session cookie.
11const SessionCookieName = "AuthSession"
12
13// UserPrefix is the mandatory CouchDB user prefix.
14// See http://docs.couchdb.org/en/2.0.0/intro/security.html#org-couchdb-user
15const UserPrefix = "org.couchdb.user:"
16
17// EndKeySuffix is a high Unicode character (0xfff0) useful for appending to an
18// endkey argument, when doing a ranged search, as described here:
19// http://couchdb.readthedocs.io/en/latest/ddocs/views/collation.html#string-ranges
20//
21// Example, to return all results with keys beginning with "foo":
22//
23//    rows, err := db.Query(context.TODO(), "ddoc", "view", map[string]interface{}{
24//        "startkey": "foo",
25//        "endkey":   "foo" + kivik.EndKeySuffix,
26//    })
27const EndKeySuffix = string(0xfff0)
28
29// HTTP methods supported by CouchDB. This is almost an exact copy of the
30// methods in the standard http package, with the addition of MethodCopy, and
31// a few methods left out which are not used by CouchDB.
32const (
33	MethodGet    = "GET"
34	MethodHead   = "HEAD"
35	MethodPost   = "POST"
36	MethodPut    = "PUT"
37	MethodDelete = "DELETE"
38	MethodCopy   = "COPY"
39)
40
41// HTTP response codes permitted by the CouchDB API.
42// See http://docs.couchdb.org/en/1.6.1/api/basics.html#http-status-codes
43const (
44	StatusOK               = 200
45	StatusCreated          = 201
46	StatusAccepted         = 202
47	StatusFound            = 302
48	StatusNotModified      = 304
49	StatusBadRequest       = 400
50	StatusUnauthorized     = 401
51	StatusForbidden        = 403
52	StatusNotFound         = 404
53	StatusMethodNotAllowed = 405
54
55	// StatusResourceNotAllowed is a misspelling of StatusMethodNotAllowed
56	StatusResourceNotAllowed          = 405
57	StatusRequestTimeout              = 408
58	StatusConflict                    = 409
59	StatusPreconditionFailed          = 412
60	StatusStatusRequestEntityTooLarge = 413
61
62	// StatusBadContentType is a misspelling of StatusUnsupportedMediaType
63	StatusBadContentType               = 415
64	StatusUnsupportedMediaType         = 415
65	StatusRequestedRangeNotSatisfiable = 416
66	StatusExpectationFailed            = 417
67	StatusInternalServerError          = 500
68
69	// StatusNotImplemented is not returned by CouchDB proper. It is used by
70	// Kivik for optional features which are not implemented by some drivers.
71	StatusNotImplemented = 501
72
73	// Error status over 600 are obviously not proper HTTP errors at all. They
74	// are used for kivik-generated errors of various types.
75
76	// StatusUnknownError is used for unclassified errors generated by Kivik,
77	// generally caused by a programming error.
78	StatusUnknownError = 600
79
80	// StatusNetworkError represents an error that occurred outside of the HTTP
81	// transport, such as a problem contacting the remote server.  This code is
82	// used to distinguish from actual HTTP-layer errors.
83	StatusNetworkError = 601
84
85	// StatusBadResponse indicates that the server responded with unrecognized
86	// data.
87	StatusBadResponse = 602
88
89	// StatusIteratorUnusable indicates an improper use of an iterator, such as
90	// calling an iterator prematurely, or after it was closed.
91	StatusIteratorUnusable = 603
92)
93