Skip to content

Application to store geolocation data based on IP or URL.

Notifications You must be signed in to change notification settings

smog29/geolocation_app

Repository files navigation

README

About

Application to store geolocation data based on IP or URL.

How to run the application:

rm config/credentials.yml.enc
rails credentials:edit
  • Open config/master.key

  • Add secrets to .env:

POSTGRES_HOST=localhost
POSTGRES_DB=<db_name>
POSTGRES_USER=<db_user>
POSTGRES_PASSWORD=<db_password>
RAILS_MASTER_KEY=<generated_master_key>
IPSTACK_API_KEY=<IPSTACK_API_KEY>
RAILS_ENV=development # development or production
  • Run the containers:
docker-compose build
docker-compose up
  • Generate test data:
docker exec -it <container_id> bundle exec rails db:seed

Running the API:

The API operates using JSON

  • List geolocations:
get http://localhost:3000/api/v1/geolocations/
  • Add geolocation:
post http://localhost:3000/api/v1/geolocations/
{
  "address": "www.wp.pl"
}

address could be a url or an IP address in all requests:

post http://localhost:3000/api/v1/geolocations/
{
  "address": "212.77.98.9"
}
  • Show geolocation (from db):
get http://localhost:3000/api/v1/geolocations/find
{
  "address": "www.wp.pl"
}
  • Update geolocation:
put http://localhost:3000/api/v1/geolocations/update
{
  "address": "www.wp.pl"
}
  • Delete geolocation:
delete http://localhost:3000/api/v1/geolocations/delete
{
  "address": "www.wp.pl"
}

About

Application to store geolocation data based on IP or URL.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published