Compare commits

...

3 commits

Author SHA1 Message Date
19f56f96cd Merge branch 'main' into logs 2023-10-05 23:57:57 +02:00
Ada
31767fd38a add(config): empty example 2023-10-04 01:06:47 +02:00
Ada
0c74258e35 add(backend): add url to have raw paste 2023-10-04 00:10:29 +02:00
3 changed files with 15 additions and 3 deletions

6
.env.example Normal file
View file

@ -0,0 +1,6 @@
PLAKKEN_HOST=0.0.0.0
PLAKKEN_PORT=3000
PLAKKEN_REDIS_ADDR=localhost:6379
PLAKKEN_REDIS_USER=
PLAKKEN_REDIS_PASSWORD=
PLAKKEN_REDIS_DB=0

10
db.go
View file

@ -28,9 +28,15 @@ func insertPaste(key string, content string, secret string, ttl time.Duration) {
content: content,
secret: secret,
}
connectDB().HSet(ctx, key, "content", hash.content)
connectDB().HSet(ctx, key, "secret", hash.secret)
db := connectDB()
db.HSet(ctx, key, "content", hash.content)
db.HSet(ctx, key, "secret", hash.secret)
if ttl > -1 {
connectDB().Do(ctx, key, ttl)
}
}
func getContent(key string) string {
db := connectDB()
return db.HGet(ctx, key, "content").Val()
}

View file

@ -11,7 +11,7 @@ import (
var currentConfig config
func handleRequest(w http.ResponseWriter, r *http.Request) {
path := r.URL.Path
path := strings.ReplaceAll(r.URL.Path, "/raw", "")
switch r.Method {
case "GET":
if path == "/" {