command
module
Version:
v0.0.0-...-47e58eb
Opens a new window with list of versions in this module.
Published: Jun 2, 2021
License: MIT
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
tgo_flattener
This is a simple server that receive a multilevel arrays and returns a flat array and the max depth of it.
Requirements
- Clone this repo
- This beta version use MongoDB 4.2.3+ for running local and for tests. You need to install it a run on default port
:27017
.
- Install go 1.16.3+.
- IMPORTANT: if you don't have
go mod
enabled, see this article
How to run the tests
- Put MongoDB to run on port
:27017
- Open the terminal, go to the root folder of this app and execute
go test ./...
How to run the app
- Put MongoDB to run on port :27017
- Open the terminal, go to the root folder of this app and execute
go run main.go
. This will run on port :8080
ENDPOINTS
- URL
POST /flats
- INFO: This will accept a JSON array with nested arrays of simple values like
string
, int
, float
and even null
- RESPONSE:
- 404: if you send an object value inside the array
- 500: this is work in progress and the algorithm should be improved
- 200: returns an JSON object with the flatted array and max depth of it
[
"0_lvl",
[
"1_lvl"
],
1,
2,
3
]
{
"max_depth": 1,
"flatted_data": [3,"0_lvl","1_lvl",1,2]
}
- URL
GET /flats
- RESPONSE:
- 500: this is work in progress and the algorithm should be improved
- 200: returns a JSON array with the last 100 items processed with the ID, the time from when this was processed, the flatted and unflatted array
[
{
"id": "60b5a1727c09e9d6a3cefec4",
"processed_at": "2021-06-01T02:54:42.088Z",
"unflatted": [
2,
3,
"0_lvl",
[
"1_lvl"
],
1
],
"flatted": ["0_lvl","1_lvl",1,2,3]
}
]
Documentation
¶
There is no documentation for this package.
Source Files
¶
Directories
¶
|
|
|
|
|
|
Package flattener is a generated GoMock package.
|
Package flattener is a generated GoMock package. |
internal
|
|
|
|
|
|
Click to show internal directories.
Click to hide internal directories.