Categorygithub.com/kyledinh/datawasher
modulepackage
0.0.0-20210520184004-7471f2941487
Repository: https://github.com/kyledinh/datawasher.git
Documentation: pkg.go.dev

# README

Project

This project illustrates the use of Docker with Go to build a RESTful service to transform data. It provides a service through a simple container.

Technologies used

Running the Docker container

In the dist-linux folder, there is the datawasherLinux server and support config and test files. To run this service as a container, just use:

In the docker folder.

linux-docker-build.sh
linux-docker-up.sh

Using the datawasher services

GET Create endpoint

http://localhost:8000/create?limit=10&first_name=MOX_RFN&last_name=MOX_RLN&email=MOX_EMAIL&addr=MOX_RSA&code=MOX_RI_1000&state=MOX_STATE&sex=MOX_RSMF

The create endpoint will generate an array of where the you can name the fields and use generator via the query string. In the example, the fields in the url param maps to the JSON fields created.

Other GET endpoints

These endpoints will return JSON objects. These contacts are predefined from the data/contacts.csv file.

http://localhost:8000/random_contact
http://localhost:8000/contacts

POST endpoints

This endpoint will transform POST a JSON payload of contacts and return the same payload with transformed first_names.

http://localhost:8000/json_contacts

See testing/post-upload-contacts.sh for a curl command to test the endpoint.

After datawashing

http://localhost:8000/washer?last_name=MOX_RLN&first_name=MOX_RFN&email=MOX_EMAIL

See testing/post-washer.sh for a curl command to test the endpoint. This endpoint allows you to describe the fields used in your json payload. In the query string you can map your fields to presets of "washer" functions.

Washer Presets
MOX_RFNTransforms with a random first name
MOX_RLNTransforms with a random last name
MOX_EMAILUsed with MOX_RFN and MOX_RLN to generate an email address
MOX_RSARandom street address like: 123 Elm Street
MOX_RI_100Random integer from 0-99
MOX_RI_1000Random integre from 0-999
MOX_STATERandom state code of 50 US states, ie: CA
MOX_RSMFRandom sex flag, connected with first name

Development

Docker Dev Container
docker pull kyledinh/devlinux
docker/launch-dev-container.sh

You will need to customize docker/launch-dev-container for where you place your source code and $GOPATH on your host:

  • -v /Users/kyle/src:/opt/src
  • -w "/opt/src/github.com/kyledinh/datawasher"

The $GOPATH is set to /opt. I would attach my host's GOPATH to this directory and set a volume to /opt/src.

Dev Resources

# Packages

No description provided by the author