A simple QRCode Encoder API in .NET 6 using ZXing and published as an Azure API App.
Windows Only - Currently this controller uses features from System.Drawing.Common
which only work on Windows platforms therefore the service must be run as a Windows App Service at this time. Please submit an issue if needed on other platforms and will prioritize the change when requested. Thanks for your understanding.
For examples running on localhost (e.g. local development), please see manualTesting.http
Once running as a website, simply call
GET http://yoursite.com/api/encode?text=SomeTextToEncode&size=200
Additionally you may send text as text/plain
to make it easier to send blocks of text without URL encoding them. Example of that call is here:
POST http://localhost:5000/api/encode?size=500
Content-Type: text/plain
Some text or URL to encode goes here
Added the ability to optionally use Basic Authentication to secure the API with one or more User/Password combinations using classic RFC 2617 HTTP authentication. In order to leverage this functionality, please use the appsettings.json
file to enable basic authentication, provide your "realm" (typically your API's url), and point to the json file where your users are listed (defaults to the provided authorizedUsers.json
):
"AppSettings" : {
"BasicAuth" : {
"Enabled" : false, # change this to true
"Realm" : "example-realm.com", # change this to your API's Domain
"UsersJson" : "authorizedUsers.json" # change this (if necessary) to the json file with authorized users
}
}
The Authorized Users are simply stored in a json file in the following format:
{
"testUser" : "testPassword",
"devUser" : "devPassword"
}
PLEASE DO NOT check userID's or passwords into your forked repo!
This leverages much of the work others have performed ahead of me. Special thanks to GitHub Contributors Including: