package
1.0.0
Repository: https://github.com/nanmu42/qrcode-api.git
Documentation: pkg.go.dev

# README

QR Code API

Encoding

Request:

GET /encode?content=helloWorld&size=400&type=png

Params:

  • content required
  • size QR Code size in pixel, may not be honored
  • type png(default) or string

Response:

  • HTTP status 200 OK

A image/png or plain text(type=string).

  • HTTP status 400 Bad Request

Check your params.

  • HTTP status 500

Something unexpected happened.

Decoding

Request:

POST /decode

Params: image as binary body

Response:

  • HTTP status 200 OK

Good decoding:

{
    "ok": true,
    "desc": "",
    "content": [
        "你好"
    ]
}

Everything is ok, but nothing recognized:

{
    "ok": true,
    "desc": "",
    "content": null
}

Something is wrong:

{
    "ok": false,
    "desc": "file decoding error: image: unknown format",
    "content": null
}
  • HTTP status 413 Request Entity Too Large

Request Body is too large.

  • HTTP status 500

Something unexpected happened.

Build

You need have Zbar library installed, whose details can be found at README.md in project root.

./build.sh

Run

cp config_example.toml config.toml
# after editing config.toml per your need
./run.sh

# Functions

DecodeQRCode controller to decode QR Code.
EncodeQRCode controller to encode QR code per request.
ParseEncodeRequest convert encoding request to struct.
RequestLogger logs every request via zap.

# Variables

BuildDate build params.
C global settings.
Version build params.

# Structs

DecodeResponse content holder for response.
Setting is where config lies.