feat(qrApi): data now passed as query string
Build and Push Docker image / build-and-push (push) Successful in 3m35s Details

For better use in markdown etc the data for the qr code is now passed als query string instead of the json body
This commit is contained in:
Valentin Kolb 2024-03-27 19:43:54 +01:00
parent ad0c60cc4f
commit d7f3369e0a
2 changed files with 15 additions and 17 deletions

View File

@ -124,7 +124,7 @@ zum Generieren von QR-Codes in SVG anbietet.
#### API Route
Das Package bietet die Route `GET /api/qr/v1` an, welche die folgenden
Parameter als json entgegennimmt:
Parameter als query string entgegennimmt:
| Parameter | Datentyp | Beschreibung |
|-------------------|-------------|------------------------------------------------------------------------------------------------|
@ -138,7 +138,7 @@ Parameter als json entgegennimmt:
#### Beispiel
```bash
curl -X GET https://it.stuve.uni-ulm.de/api/qr/v1 -d '{"data": "https://stuve.uni-ulm.de"}'
curl -X GET https://it.stuve.uni-ulm.de/api/qr/v1?data=stuve.uni-ulm.de
```
### LDAP API

View File

@ -16,16 +16,14 @@ import (
// this endpoint can be used to create qr codes
// GET /api/qr/v1
//
// the endpoint expects the following request data:
// the endpoint expects the following query params:
//
// {
// "data": "what to be encoded",
// "ecc": "error correction level ('L', 'M' (default), 'Q', 'H')",
// "scale": "scale of qr code (default 1), must be greater than 0",
// "border": "border of qr code (default 1), must be equal or greater than 0, one is equal to one qr-code 'pixel'"
// "color": "color of qr code (default #000000)"
// "colorBackground": "background color of qr code (default #FFFFFF)",
// }
// "data": "what to be encoded",
// "ecc": "error correction level ('L', 'M' (default), 'Q', 'H')",
// "scale": "scale of qr code (default 1), must be greater than 0",
// "border": "border of qr code (default 1), must be equal or greater than 0, one is equal to one qr-code 'pixel'"
// "color": "color of qr code (default #000000)"
// "colorBackground": "background color of qr code (default #FFFFFF)",
//
// if the user is authenticated successfully the endpoint returns and apis.RecordAuthResponse
func InitQRApi(app *pocketbase.PocketBase, e *core.ServeEvent) error {
@ -37,12 +35,12 @@ func InitQRApi(app *pocketbase.PocketBase, e *core.ServeEvent) error {
// get data from request
data := struct {
Data string `json:"data"`
ECC string `json:"ecc"`
Scale int `json:"scale"`
Border int `json:"border"`
ColorDark string `json:"color"`
ColorLight string `json:"colorBackground"`
Data string `query:"data"`
ECC string `query:"ecc"`
Scale int `query:"scale"`
Border int `query:"border"`
ColorDark string `query:"color"`
ColorLight string `query:"colorBackground"`
}{}
if err := c.Bind(&data); err != nil {
return apis.NewBadRequestError("Failed to read request data", err)