1
0
mirror of https://github.com/lus/pasty.git synced 2023-08-10 21:13:09 +03:00

Include AutoDelete lifetime in /api/v2/info response

This commit is contained in:
Lukas Schulte Pelkum 2022-01-29 16:18:40 +01:00
parent 12a60526f9
commit c7fcdeb91c
No known key found for this signature in database
GPG Key ID: 408DA7CA81DB885C
2 changed files with 10 additions and 4 deletions

9
API.md
View File

@ -69,10 +69,11 @@ GET /api/v2/info
none
**Response:**
```json
```jsonc
{
"modificationTokens": true,
"reports": true,
"pasteLifetime": -1, // The configured AutoDelete paste lifetime; -1 if AutoDelete is disabled
"version": "dev"
}
```
@ -94,7 +95,7 @@ none
"id": "paste_id",
"content": "paste_content",
"created": 0000000000,
"metadata": {},
"metadata": {}
}
```
@ -121,7 +122,7 @@ POST /api/v2/pastes
"content": "paste_content",
"modificationToken": "raw_modification_token",
"created": 0000000000,
"metadata": {},
"metadata": {}
}
```
@ -147,7 +148,7 @@ PATCH /api/v2/pastes/{paste_id}
"id": "paste_id",
"content": "new_paste_content",
"created": 0000000000,
"metadata": {},
"metadata": {}
}
```

View File

@ -71,11 +71,16 @@ func Serve() error {
v2Route := apiRoute.Group("/v2")
{
pasteLifetime := int64(-1)
if config.Current.AutoDelete.Enabled {
pasteLifetime = config.Current.AutoDelete.Lifetime.Milliseconds()
}
v2Route.GET("/info", func(ctx *fasthttp.RequestCtx) {
jsonData, _ := json.Marshal(map[string]interface{}{
"version": static.Version,
"modificationTokens": config.Current.ModificationTokens,
"reports": config.Current.Reports.Reports,
"pasteLifetime": pasteLifetime,
})
ctx.SetBody(jsonData)
})