feat(qrApi): data now passed as query string
Build and Push Docker image / build-and-push (push) Successful in 3m35s
Details
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:
parent
ad0c60cc4f
commit
d7f3369e0a
|
@ -124,7 +124,7 @@ zum Generieren von QR-Codes in SVG anbietet.
|
||||||
#### API Route
|
#### API Route
|
||||||
|
|
||||||
Das Package bietet die Route `GET /api/qr/v1` an, welche die folgenden
|
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 |
|
| Parameter | Datentyp | Beschreibung |
|
||||||
|-------------------|-------------|------------------------------------------------------------------------------------------------|
|
|-------------------|-------------|------------------------------------------------------------------------------------------------|
|
||||||
|
@ -138,7 +138,7 @@ Parameter als json entgegennimmt:
|
||||||
#### Beispiel
|
#### Beispiel
|
||||||
|
|
||||||
```bash
|
```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
|
### LDAP API
|
||||||
|
|
|
@ -16,16 +16,14 @@ import (
|
||||||
// this endpoint can be used to create qr codes
|
// this endpoint can be used to create qr codes
|
||||||
// GET /api/qr/v1
|
// GET /api/qr/v1
|
||||||
//
|
//
|
||||||
// the endpoint expects the following request data:
|
// the endpoint expects the following query params:
|
||||||
//
|
//
|
||||||
// {
|
// "data": "what to be encoded",
|
||||||
// "data": "what to be encoded",
|
// "ecc": "error correction level ('L', 'M' (default), 'Q', 'H')",
|
||||||
// "ecc": "error correction level ('L', 'M' (default), 'Q', 'H')",
|
// "scale": "scale of qr code (default 1), must be greater than 0",
|
||||||
// "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'"
|
||||||
// "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)"
|
||||||
// "color": "color of qr code (default #000000)"
|
// "colorBackground": "background color of qr code (default #FFFFFF)",
|
||||||
// "colorBackground": "background color of qr code (default #FFFFFF)",
|
|
||||||
// }
|
|
||||||
//
|
//
|
||||||
// if the user is authenticated successfully the endpoint returns and apis.RecordAuthResponse
|
// if the user is authenticated successfully the endpoint returns and apis.RecordAuthResponse
|
||||||
func InitQRApi(app *pocketbase.PocketBase, e *core.ServeEvent) error {
|
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
|
// get data from request
|
||||||
data := struct {
|
data := struct {
|
||||||
Data string `json:"data"`
|
Data string `query:"data"`
|
||||||
ECC string `json:"ecc"`
|
ECC string `query:"ecc"`
|
||||||
Scale int `json:"scale"`
|
Scale int `query:"scale"`
|
||||||
Border int `json:"border"`
|
Border int `query:"border"`
|
||||||
ColorDark string `json:"color"`
|
ColorDark string `query:"color"`
|
||||||
ColorLight string `json:"colorBackground"`
|
ColorLight string `query:"colorBackground"`
|
||||||
}{}
|
}{}
|
||||||
if err := c.Bind(&data); err != nil {
|
if err := c.Bind(&data); err != nil {
|
||||||
return apis.NewBadRequestError("Failed to read request data", err)
|
return apis.NewBadRequestError("Failed to read request data", err)
|
||||||
|
|
Loading…
Reference in New Issue