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

Switch from snowflake to random string ID system

This commit is contained in:
Lukas SP
2020-08-24 20:22:53 +02:00
parent a1cd915759
commit 5585a26ab0
13 changed files with 97 additions and 65 deletions

View File

@@ -24,8 +24,16 @@ func HastebinSupportHandler(ctx *fasthttp.RequestCtx) {
return
}
// Acquire the paste ID
id, err := storage.AcquireID()
if err != nil {
ctx.SetStatusCode(fasthttp.StatusInternalServerError)
ctx.SetBodyString(err.Error())
return
}
// Create the paste object
paste, err := pastes.Create(content)
paste, err := pastes.Create(id, content)
if err != nil {
ctx.SetStatusCode(fasthttp.StatusInternalServerError)
ctx.SetBodyString(err.Error())
@@ -50,7 +58,7 @@ func HastebinSupportHandler(ctx *fasthttp.RequestCtx) {
// Respond with the paste key
jsonData, _ := json.Marshal(map[string]string{
"key": paste.ID.String(),
"key": paste.ID,
})
ctx.SetBody(jsonData)
}