Skip to content

A small educational REST API using Go gin that validates card numbers using Luhn algorithm

Notifications You must be signed in to change notification settings

vladNed/card-validation-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Card Validation Service

This is a simple service that validates credit card numbers using the Luhn algorithm. It is an educational project that I created to learn more about the Go programming language and gin framework.

Running the service

To install the service, you need to have Go installed on your machine. You can download it from the official website.

Running in development mode

go run cmd/card-service/main.go

Running in production mode

go build -o card-service cmd/card-service/main.go
./card-service

Running in a container

docker build -t card-service .
docker run --name card-service -p 8080:8080 --env-file .env card-service

Endpoints

GET /ping

It returns a simple pong message.

Response

{
  "message": "pong"
}

POST /validate

It validates a credit card number using the Luhn algorithm.

Request

{
  "card_number": "4111111111111111"
}

Response

{
  "valid": true
}

Running tests

go test ./internal/...

About

A small educational REST API using Go gin that validates card numbers using Luhn algorithm

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published