go-and-find-with-go

command module
v0.0.0-...-738bcfb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2021 License: MIT Imports: 9 Imported by: 0

README

go-lang Demonstrator Application

go-and-find-with-go is a prototype application demonstrating good use of go-lang language features and how to properly structure a testable web application. It covers many language features and aspects around TDD found in a commercial environment.

READ THIS before you do anything!

This application is only for learning and demonstration purposes and shall not be used for anything else and comes with absolutely no warranty or support of any kind whatsoever.

Get a property entry
Request

GET /system-settings

curl -i -H 'Accept: application/json' http://localhost:8080/system-settings
Response
HTTP/1.1 200 OK
Date: Mon, 12 Apr 2021 14:55:13 GMT
Content-Length: 280
Content-Type: text/plain; charset=utf-8

[{"property-name":"prop1","property-value":""...,"GroupDescription":"Group level Description"}]
  • Error Response:
    • Code: 500
      Content: { error : "Error reading from the database" }

Get properties for a group
Request

GET /system-settings/group-code/{group-code} OR GET /system-settings/group-name/{group-name}

curl -i -H 'Accept: application/json' http://localhost:8080/system-settings/group-code/main_group
Response
HTTP/1.1 200 OK
Date: Mon, 12 Apr 2021 15:11:32 GMT
Content-Length: 280
Content-Type: text/plain; charset=utf-8

[{"property-name":"prop1","property-value":""...,"GroupDescription":"Group level Description"}]
  • Error Response:
    • Code: 500
      Content: { error : "Error reading from the database" }

Add property data as json
Request
`POST /system-settings/`
curl -i -H 'Accept: application/json' http://localhost:8080/system-settings/group-code/main_group
Response
HTTP/1.1 200 OK
Date: Mon, 12 Apr 2021 15:11:32 GMT
Content-Length: 280
Content-Type: text/plain; charset=utf-8

[{"property-name":"prop1","property-value":""...,"GroupDescription":"Group level Description"}]
  • Error Response:
    • Code: 422 UNPROCESSABLE ENTITY
      Content: {"validation failure"} OR
    • Code: 500
      Content: { error : "Error adding data to the database" }

Installation

GO needs to be installed. Here are the actual steps for running the application.

  • rm go.mod (if already present)
  • go mod init github.com/{you-username}/go-and-find-with-go
  • go mod vendor
  • go get
  • cd test
  • go test
  • cd ..
  • go run main.go (starts the http service)

Mongo Schema

Two tables need to be created.

CREATE TABLE "SETTINGS_GROUP" ( id integer, group_code character varying COLLATE pg_catalog."default", group_name character varying COLLATE pg_catalog."default", description character varying COLLATE pg_catalog."default" )

CREATE TABLE "SYSTEM_SETTINGS" ( property_name character varying(100), property_value character varying(100), default_value character varying(100), description character varying(100), data_type character varying(100), enabled int , active_from_date time, group_code character varying(10) )

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss your change.

Please make sure to update tests as appropriate.

License

MIT

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
config

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL