mirror of
https://github.com/JustKato/FreePad.git
synced 2026-02-24 00:00:46 +02:00
Bunch more updates
This commit is contained in:
@@ -7,5 +7,6 @@ require (
|
||||
github.com/go-sql-driver/mysql v1.6.0
|
||||
github.com/golang-migrate/migrate/v4 v4.15.2
|
||||
github.com/mattn/go-sqlite3 v1.14.13
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect
|
||||
github.com/ulule/limiter/v3 v3.10.0
|
||||
)
|
||||
|
||||
@@ -1014,6 +1014,8 @@ github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrf
|
||||
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
|
||||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
|
||||
func main() {
|
||||
|
||||
_, isRelease := os.LookupEnv("RELEASE_MODE")
|
||||
if isRelease {
|
||||
_, isDevelopment := os.LookupEnv("IS_DEV")
|
||||
if isDevelopment {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
@@ -8,6 +9,7 @@ import (
|
||||
"github.com/JustKato/FreePad/helper"
|
||||
"github.com/JustKato/FreePad/types"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/skip2/go-qrcode"
|
||||
)
|
||||
|
||||
func ApiRoutes(route *gin.RouterGroup) {
|
||||
@@ -66,6 +68,31 @@ func ApiRoutes(route *gin.RouterGroup) {
|
||||
// Add in health checks
|
||||
route.GET("/health", healthCheck)
|
||||
|
||||
route.POST("/qr", func(ctx *gin.Context) {
|
||||
|
||||
// Get the name of the post
|
||||
link := ctx.PostForm("link")
|
||||
|
||||
// store the png somewhere
|
||||
var png []byte
|
||||
|
||||
// Encode the link into a qr code
|
||||
png, err := qrcode.Encode(link, qrcode.High, 512)
|
||||
if err != nil {
|
||||
ctx.JSON(200, types.FreeError{
|
||||
Error: fmt.Sprint(err),
|
||||
Message: "Failed to convert qr Code",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Write the png to the response
|
||||
ctx.JSON(200, gin.H{
|
||||
"message": "Succesfully generated the QR",
|
||||
"qr": "data:image/jpeg;base64," + base64.StdEncoding.EncodeToString(png),
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func healthCheck(ctx *gin.Context) {
|
||||
|
||||
Reference in New Issue
Block a user