Skip to content

Latest commit

 

History

History
104 lines (75 loc) · 3.17 KB

README.md

File metadata and controls

104 lines (75 loc) · 3.17 KB

orca-lookup-go

This open source project is a an example of how to scan barcodes using a smartphone and present data from your system using Go and the gin framework.

How it works:

  1. A user scans a barcode using their smartphone
  2. Orca Scan sends a HTTP GET request to your endpoint with ?barcode=value
  3. Your system queries a database or internal API for a barcode match
  4. Your system returns the data in JSON format with keys matching column names
  5. The Orca Scan mobile app presents that data to the user

If the mobile user has update permission and saves the data, it will saved to your Orca sheet.

Install

First ensure you have Go installed:

# should return 1.13 or higher
go version

Then execute the following:

# download this example code
git clone https://github.com/orca-scan/orca-lookup-go.git

# go into the new directory
cd orca-lookup-go

# install dependencies
go get -d ./...

If you get an error from this command like "go.mod file not found in current directory or any parent directory.", enter the following command, then try again:

go env -w GO111MODULE=auto

Run

# start the project
go run main.go

Visit http://localhost:5000?barcode=4S3BMHB68B3286050 to see the following:

{
    "VIN": "4S3BMHB68B3286050",
    "Make": "SUBARU",
    "Model": "Legacy",
    "Manufacturer Name": "FUJI HEAVY INDUSTRIES U.S.A",
    "Vehicle Type": "PASSENGER CAR",
    "Year": 1992
}

How this example works

This simple example uses the gin framework:

// GET / handler
router.GET("/", func(c *gin.Context) {

  // get the incoming barcode sent from Orca Scan (scanned by a user)
  barcode := c.Query("barcode")

  // TODO: query a database or API to retrieve some data based on barcode value

  // return data as JSON object (property names must match Orca column names)
  c.JSON(200, gin.H{
    "VIN": barcode,
    "Make": "SUBARU",
    "Model": "Legacy",
    "Manufacturer Name": "FUJI HEAVY INDUSTRIES U.S.A",
    "Vehicle Type": "PASSENGER CAR",
    "Year": 1992,
  })
})

Troubleshooting

If you run into any issues not listed here, please open a ticket.

Examples in other langauges

History

For change-log, check releases.

License

Licensed under MIT License © Orca Scan, the Barcode Scanner app for iOS and Android.