all repos — litestore @ b8357c42f9dcbe15a16f17ba227dece59e13b28a

A minimalist nosql document store.

src/admin/md/nim-api_high.md

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
### High-Level Nim API

The following [proc](class:kwd)s map 1:1 to the corresponding HTTP methods. This API is recommended for most uses, as every method triggers exactly the same logic as the corresponding HTTP request.

{{ p-resource => resource
: The resource to perform the operation on ([info](class:kwd) or [docs](class:kwd)).}}
{{ p-params => params
: The parameters to pass to the operation (see the corresponding HTTP querystring parameters).}}
{{ p-id => id 
: The identifier of the resource (set to an empty string if not needed).}}
{{ p-body => body
: The request body. }}
{{ p-headers => headers 
: An [HttpHeaders](class:kwd) object containing the headers of the request. Use the [Content-Type](class:kwd) header to specify the content type of the [body](class:kwd) parameter.}}

#### get

     proc get*(resource, id: string, params = newStringTable(), headers = newHttpHeaders()): LSResponse

Retrieves a resource.

##### Parameters

{{p-resource}}
{{p-id}}
{{p-params}}
{{p-headers}}

#### post

     proc post*(resource, id, body: string, headers = newHttpHeaders()): LSResponse

Creates a new resource.

##### Parameters

{{p-resource}}
{{ p-folder => folder 
: The folder that will contain the resource (set to an empty string if not needed).}}
{{p-body}}
{{p-headers}}

#### put

     proc put*(resource, id, body: string, headers = newHttpHeaders()): LSResponse

Modifies an existing resource.

##### Parameters

{{p-resource}}
{{p-id}}
{{p-body}}
{{p-headers}}

#### patch

     proc patch*(resource, id, body: string, headers = newHttpHeaders()): LSResponse

Modifies the tags of an existing resource.

##### Parameters

{{p-resource}}
{{p-id}}
{{p-body}}
{{p-headers}}

#### delete

     proc delete*(resource, id: string, headers = newHttpHeaders()): LSResponse

Deletes an existing resource.

##### Parameters

{{p-resource}}
{{p-id}}
{{p-headers}}

#### head

     proc head*(resource, id: string, headers = newHttpHeaders()): LSResponse

Checks whether a resource exists or not.

##### Parameters

{{p-resource}}
{{p-id}}
{{p-headers}}

#### options

     proc options*(resource, id: string, headers = newHttpHeaders()): LSResponse

Checks what HTTP methods are supported by the specified resource.

##### Parameters

{{p-resource}}
{{p-id}}
{{p-headers}}