Matrix Handling Web Server
Program to handle a matrix from a CSV file and perform a few operations on it.
Table of Contents
-
About The Project
-
Getting Started
- Usage
- Future improvements
- Contributing
- License
- Contact
About The Project
This is a simple project to handle a matrix from a CSV file and perform a few operations on it.
Given an uploaded csv file
1,2,3
4,5,6
7,8,9
The following operations should be available:
- Echo
- Return the matrix as a string in matrix format.
// Expected output
1,2,3
4,5,6
7,8,9
- Invert
- Return the matrix as a string in matrix format where the columns and rows are inverted
// Expected output
1,4,7
2,5,8
3,6,9
- Flatten
- Return the matrix as a 1 line string, with values separated by commas.
// Expected output
1,2,3,4,5,6,7,8,9
- Sum
- Return the sum of the integers in the matrix
// Expected output
45
- Multiply
- Return the product of the integers in the matrix
// Expected output
362880
The input file to these functions is a matrix, of any dimension where the number of rows are equal to the number of columns (square). Each value is an integer, and there is no header row. resources/matrix.csv
is an example of a valid input.
Built With
Getting Started
To get a local copy up and running follow these simple steps.
Prerequisites
Make sure Go is installed in your machine. Run the following command to confirm:
$ go version
go version go1.14 windows/amd64
Installation
- Clone the repo
$ git clone https://github.com/julioromanoreal/matrix-operations.git
- Start the application
$ go run cmd/matrix-operations/main.go
Usage
The following endpoints will be available:
- Echo:
http://localhost:8080/echo
:
curl -F 'file=@/path/matrix.csv' "localhost:8080/echo"
- Flatten:
http://localhost:8080/flatten
:
curl -F 'file=@/path/matrix.csv' "localhost:8080/flatten"
- Invert:
http://localhost:8080/invert
:
curl -F 'file=@/path/matrix.csv' "localhost:8080/invert"
- Sum:
http://localhost:8080/sum
:
curl -F 'file=@/path/matrix.csv' "localhost:8080/sum"
- Multiply:
http://localhost:8080/multiply
:
curl -F 'file=@/path/matrix.csv' "localhost:8080/multiply"
Future improvements
- Consider protecting the URLs using JWT
- Consider using gorilla/mux in the web server
Contributing
Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
)
- Commit your Changes (
git commit -m 'Add some AmazingFeature'
)
- Push to the Branch (
git push origin feature/AmazingFeature
)
- Open a Pull Request
License
Distributed under the MIT License. See LICENSE
for more information.
Julio Romano - @julioromano_ - julio.romano@gmail.com
Project Link: https://github.com/julioromanoreal/matrix-operations