all repos — litestore @ 5646cbba2dc69517cb99e66dfd4b5e841993d3ce

A minimalist nosql document store.

src/admin/md/api_assets.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
### assets (LiteStore Assets)

> %note%
> API v8 Required
> 
> This resource has been introduced in version 5 of the LiteStore API.

Assets represents another way to query LiteStore Documents. All documents can also be retrieved via `/assets/` instead of docs, but when doing so:
* a non-raw version of the document will always be returned
* when querying a folder without specifying a document ID, LiteStore will attempt to retrieve an `index.html` or `index.htm` file within that folder

This is particularly useful when your documents have been imported from the filesystem and you need to effectively serve files.

#### OPTIONS assets

Returns the allowed HTTP verbs for this resource.

##### Example

```
$ curl -i -X OPTIONS 'http://127.0.0.1:9500/assets'
HTTP/1.1 200 OK
Content-Length: 0
Access-Control-Allow-Methods: GET,OPTIONS
Allow: GET,OPTIONS
Access-Control-Allow-Headers: Content-Type
Access-Control-Allow-Origin: *
Server: LiteStore/1.12.0
```

#### OPTIONS assets/:id

Returns the allowed HTTP verbs for this resource.

##### Example

```
curl -i -X OPTIONS 'http://127.0.0.1:9500/assets/test.json' 
HTTP/1.1 200 OK
Content-Length: 0
Access-Control-Allow-Methods: GET,OPTIONS
Allow: GET,OPTIONS
Access-Control-Allow-Headers: Content-Type
Access-Control-Allow-Origin: *
Server: LiteStore/1.12.0
```

#### OPTIONS assets/:folder/

Returns the allowed HTTP verbs for this resource.

##### Example

```
$ curl -i -X OPTIONS 'http://127.0.0.1:9500/assets/test/'
HTTP/1.1 200 OK
Content-Length: 0
Access-Control-Allow-Methods: GET,OPTIONS
Allow: GET,OPTIONS
Access-Control-Allow-Headers: Content-Type
Access-Control-Allow-Origin: *
Server: LiteStore/1.12.0
```

#### GET assets

Retrieves the file `assets/index.html` or `assets/index.htm` if not found.


#### GET assets/:folder/


Retrieves the file `assets/:folder/index.html` or `assets/:folder/index.htm` if not found.

#### GET assets/:id

Retrieves the specified document. The response is returned in the document's content type (even for JSON files).

##### Example

```
$ curl -i 'http://127.0.0.1:9500/docs/test.txt'
HTTP/1.1 200 OK
Content-Length: 24
Content-Type: text/plain
Access-Control-Allow-Headers: Content-Type
Access-Control-Allow-Origin: *
Server: LiteStore/1.12.0

This is a test document.
```