Giter VIP home page Giter VIP logo

filter-rect's Introduction

Filter Rectangles!!

This service will filter all input rectangle based on given rectangle then store them into database for further use.

Run

For run this service simply run the command below:

docker-compose up -d --build

API'S

This service has 2 endpoint:

You can send your main rectangle and input rectangles to this endpoint and what it will do is that filter all input rectangles which is overlap with main rectangle then it will store them to database.

on successful return response with status code 201.

This endpoint will return all rectangles that stored in database so far.

on successful return response with status code 200.

Support other databases

This service can easily support other databases. What you should do is that implement the interface below and launch it through main function. Actually this service make access to databases through Repository design pattern.

//RectangleRepo should be implemented for all databases.
type RectangleRepo interface {

	//Query api's
	GetRectByID(ctx context.Context, Id string) *rect_model.Rectangle
	GetAllRect(ctx context.Context) []rect_model.Rectangle

	//modify api's
	Migrate(ctx context.Context)
	SaveRectangle(ctx context.Context, rect *rect_model.Rectangle) error
	UpdateRectangle(ctx context.Context, rect *rect_model.Rectangle) error
	DeleteRectangleByID(ctx context.Context, Id string) error
	DeleteAllRectangle(tx context.Context)
}

Examples

Send main rectangle and input rectangles

curl -X POST http://127.0.0.1:18080/ -d '{
    "main": {"x": 3, "y": 2, "width": 5, "height": 10},
    "inputs": [
        {"x": 4, "y": 10, "width": 1, "height": 1},
        {"x": 9, "y": 10, "width": 5, "height": 4}
    ]
}'  

Get filtered and valid rectangles

curl http://127.0.0.1:18080/

Return:

[{"x":4,"y":10,"width":1,"height":1,"time":"Mon, 11 Oct 2021 08:56:20 +0000"}]

filter-rect's People

Contributors

keyvan-dadash avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.