Git Product home page Git Product logo

numbers-api-go's Introduction

NUMBERS API GO

API that categorizes and stores numbers based on their divisibility

Go website :shipit:

Go Reference Go Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.

Gopher image Gopher image by [Renee French][rf], licensed under [Creative Commons 4.0 Attributions license][cc4-by].

Objective

Tip

Implement an API that categorizes and stores numbers based on their divisibility by 3 and 5, mimicking the logic described below:

  • Numbers divisible by 3: Categorized as "Type 1"
  • Numbers divisible by 5: Categorized as "Type 2"
  • Numbers divisible by both 3 and 5: Categorized as "Type 3"
  • Other numbers: Stored as their original value

Constraints

Caution

Utilize only one if statement within the core logic. Avoid else, else if, ternary operators, or switch statements.

Functional Requirements

Note

The API shall store numbers and their classifications in memory or any other support you consider appropriate.

Classifications include:

  • Numbers divisible by 3: Categorized as "Type 1"
  • Numbers divisible by 5: Categorized as "Type 2"
  • Numbers divisible by both 3 and 5: Categorized as "Type 3"
  • Other numbers: Stored as their original value

Number Addition:

POST localhost:8080/numbers/ The API provides a mechanism to save a number into its collection.
Body
name type data type description
number required object (JSON) {"number":25}
Responses
http code content-type response
201 application/json Created successfully
400 application/json "message": "There was an error processing the request!"

Number Retrieval:

GET localhost:8080/numbers/{number} The API allows the retrieval of a specific number's classification. If the number is not found, the API returns 404
Parameters
name type data type description
number required object (JSON) /25
Responses
http code content-type response
201 application/json {"Number": 25,"Category": "Type 2"}
404 application/json "message": "number not found"
400 application/json "message": "Can't convert this to an int!"

Collection Retrieval:

GET localhost:8080/numbers The API enables the retrieval of all stored numbers and their classifications.
Parameters
name type data type description
Responses
http code content-type response
200 application/json [{"Number": 25,"Category": "Type 2"}]

For developer Folks:

Important

Key information Developers need to know to run, mantain and evolve this project.

go version go1.22.1

How to run the project:

go mod init 
go mod tidy 
go get numbers 
go run main.go 

How to run the project test:

go run test 

numbers-api-go's People

Contributors

joaquinacuna97 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.