Documentation ¶
Overview ¶
Package iidy is a REST-like checklist or "attempt list" with a PostgreSQL backend.
Sample interaction:
$ curl localhost:8080/iidy/v1/lists/downloads/a.txt Not found. $ curl -X POST localhost:8080/iidy/v1/lists/downloads/a.txt ADDED 1 $ curl localhost:8080/iidy/v1/lists/downloads/a.txt 0 $ curl -X POST localhost:8080/iidy/v1/lists/downloads/a.txt?action=increment INCREMENTED 1 $ curl localhost:8080/iidy/v1/lists/downloads/a.txt 1 $ curl -X DELETE localhost:8080/iidy/v1/lists/downloads/a.txt DELETED 1 $ curl localhost:8080/iidy/v1/lists/downloads/a.txt Not found. $ curl -X POST localhost:8080/iidy/v1/batch/lists/downloads -d ' b.txt c.txt d.txt e.txt f.txt g.txt h.txt i.txt ' ADDED 8 $ curl localhost:8080/iidy/v1/batch/lists/downloads?count=2 b.txt 0 c.txt 0 $ curl "localhost:8080/iidy/v1/batch/lists/downloads?count=2&after_id=c.txt" d.txt 0 e.txt 0 $ curl "localhost:8080/iidy/v1/batch/lists/downloads?count=4&after_id=e.txt" f.txt 0 g.txt 0 h.txt 0 i.txt 0 $ curl localhost:8080/iidy/v1/batch/lists/downloads?action=increment -d ' b.txt c.txt d.txt e.txt ' INCREMENTED 4 $ curl localhost:8080/iidy/v1/batch/lists/downloads?count=100 b.txt 1 c.txt 1 d.txt 1 e.txt 1 f.txt 0 g.txt 0 h.txt 0 i.txt 0 $ curl -X DELETE localhost:8080/iidy/v1/batch/lists/downloads -d ' d.txt e.txt f.txt g.txt ' DELETED 4 $ curl localhost:8080/iidy/v1/batch/lists/downloads?count=100 b.txt 1 c.txt 1 h.txt 0 i.txt 0
Index ¶
Constants ¶
const BodyBytesKey string = "bodyBytes"
BodyBytesKey is the key to find the bytes from the request body in the request's context, after we put them there.
const FinalContentTypeKey string = "final Content-Type"
FinalContentTypeKey is the key to find the ContentType in the request's context, after we put it there.
const QueryKey string = "query"
QueryKey is the key to find the query parameters in the request's context, after we put them there.
Variables ¶
var HandledContentTypes = map[string]struct{}{
"text/plain": struct{}{},
"application/json": struct{}{},
}
HandledContentTypes are the content types handled by this service.
Functions ¶
This section is empty.
Types ¶
type AddedMessage ¶
type AddedMessage struct {
Added int64 `json:"added"`
}
AddedMessage informs the user how many items were added to a list. The message can be formatted either as plain text or JSON.
type DeletedMessage ¶
type DeletedMessage struct {
Deleted int64 `json:"deleted"`
}
DeletedMessage informs the user how many items were deleted from a list. The message can be formatted either as plain text or JSON.
type ErrorMessage ¶
type ErrorMessage struct {
Error string `json:"error"`
}
ErrorMessage holds an error that can be sent to the client either as plain text or JSON.
type Handler ¶
Handler handles requests to "/lists/". It contains an instance of PgStore, so that it has a place to store list data.
func (*Handler) ServeHTTP ¶
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP satisfies the http.Handler interface. It is expected to handle all traffic to the iidy server. It looks at the request and then delegates to more specific handlers depending on the request method.
type IncrementedMessage ¶
type IncrementedMessage struct {
Incremented int64 `json:"incremented"`
}
IncrementedMessage informs the user how many items were incremented in a list. The message can be formatted either as plain text or JSON.
type ItemListMessage ¶
type ItemListMessage struct {
Items []string `json:"items"`
}
ItemListMessage is a list of items that we serialize/deserialize to/from JSON when using application/json
type ListEntryMessage ¶
ListEntryMessage is a list of entries and their attempts that we serialize/deserialize to/from JSON when using application/json