Coder Social home page Coder Social logo

geoip-render-go's Introduction

geoip-render-go

Golang project for looking up geo from an IP. Meant to be deployed on Render.

Dependencies

In order to use this project, you'll need a copy of your own Maxmind GeoIP database. You can sign up for the GeoLite2 database here.

This project then relies on the oschwald/geoip2-golang package for looking up an IP in a MaxMind GeoIP database. See the documentation for all of the queries that can be made and the resulting structs.

Environment variables

This project relies on the following environment variables:

ENV Variable Description Required Default
GEO_FILE The location of your Maxmind GeoIP database (e.g., ./GeoLite2-City.mmdb) Yes None
MODE The mode to launch the application in. No "release"
PORT The port for the web service to listen on. No 3000

How to use

1. Fork Repository

Fork this repository into your own account.

2. Include your Maxmind GeoIP database

Include your Maxmind GeoIP database in the root of the project. For example, ./GeoLite2-City.mmdb. Commit this to the repository.

3. Update code

Update the handler() function in main.go to make the appropriate query and return the response.

The example in main.go uses the IP address provided to make a City() query and returns the zip code as JSON.

4. Deploy to render

Create a new web service on Render. Use your new repository and set the above environment variables to make them available at run time.

5. Make request

The web service listens for requests to /:ipaddress.

Notes

  • This project DOES NOT log web requests. It only prints status logs. If you want to log each request, you can add it to the Go Gin logger.
  • The web service responds to a 200 status code on /healthz, to be used as a health check.

geoip-render-go's People

Contributors

knation avatar

Watchers

 avatar  avatar

Forkers

sellthru

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.