Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/sooonmitch/weather-api-demo

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/sooonmitch/weather-api-demo

  • v1.0.0
  • Source
  • Go
  • Socket score

Version published
Created
Source

Weather API Demo

Purpose

The Weather API application provides weather information based on latitude and longitude. It is designed to demo a weather forecasts API and related data in a simple, RESTful manner.

Features

  • Retrieve weather data using geographical coordinates.
  • Provides temperature, weather conditions, and a description of how the temperature feels.
  • Supports CRUD operations for weather data management.

Design

Architecture

  • Language: Go
  • Framework: Gorilla Mux for routing
  • Middleware: Custom middleware for JSON responses, logging, and metrics

Endpoints

  • GET /api/v1/weather/{latitude},{longitude}: Retrieve weather information for a specific location.
  • PUT /api/v1/weather: Update weather data (not fully implemented here).
  • POST /api/v1/weather: Create new weather data (not fully implemented here).
  • DELETE /api/v1/weather: Delete weather data (not fully implemented here).

Environment Variables

NameDefault ValueDescription
SERVER_ADDRESS:8080Specifies the server address and port to bind the application to

Usage

Prerequisites

  • Go 1.22 installed on your machine.
  • Docker installed for containerization.

Running Locally

  1. Clone the repository:
git clone https://github.com/sooonmitch/weather-api-demo
cd weather-api-demo
  1. Run the application:
go run ./
  1. Access the API: Use curl or a tool like Postman to interact with the API
curl "http://localhost:8080/api/v1/weather/40,74"

Running with Docker

  1. Build the Docker image:
docker build -t app .
  1. Run the Docker container:
docker run -p 8080:8080 -e SERVER_ADDRESS=0.0.0.0:8080 app
  1. Test the API: Again, use curl or Postman:
curl "http://localhost:8080/api/v1/weather/40,74"

Releasing

Set the release tag:

git tag -a v1.0.0 -m "<Release Message>"

Push the release tag

git push origin v1.0.0

Run gorelease

goreleaser release

Testing

Run unit tests to ensure the application works as expected:

go test ./...

Notes

  • This is a demo, it will lack features and comforts
  • Modify the SERVER_ADDRESS environment variable as needed.
  • Ensure that ports used are not conflicting with other applications.

FAQs

Package last updated on 18 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc