Code Monkey home page Code Monkey logo

golang-fifa-world-cup-web-service's Introduction

FIFA World Cup Winners

This project exposes a Web API for accessing historic data from the FIFA World Cup championship.

Running tests

A proper Go environment is required in order to run this project. Once setup, tests can be run with the make test or simply make command.

Running the server

Once all tests are passing, the server can be started with the make start command.

Testing the API manually

Start the server with make start and then read the Access Token printed to standard output. This token will be used for POST requests.

GETting

curl -i http://localhost:8000/
curl -i http://localhost:8000/winners
curl -i http://localhost:8000/winners?year=1970
curl -i http://localhost:8000/winners?year=banana

POSTin with no access token

curl -i -X POST \
-d '{"country":"Croatia", "year": 2030}' http://localhost:8000/winners

POSTing with valid access token

First, start the sever and read the value for the Access Token printed to standard output.

curl -i -X POST \
-H "X-ACCESS-TOKEN: 5577006791947779410" \
-d '{"country":"Croatia", "year": 2030}' http://localhost:8000/winners

Then check for the newly added winner

curl -i http://localhost:8000/winners

POSTing with invalid data

curl -i -X POST \
-H "X-ACCESS-TOKEN: 5577006791947779410" \
-d '{"country":"Russia", "year": 1984}' http://localhost:8000/winners

POSTing with invalid method

curl -i -X PUT -d '{"country":"Russia", "year": 2030}' http://localhost:8000/winners

Running with Docker

To build the image from the Dockerfile, run:

docker build -t project-fifa-world-cup .

To start an interactive shell, run:

docker run -it --rm --name run-fifa project-fifa-world-cup

From inside the shell, run the tests with:

go test handlers/*

golang-fifa-world-cup-web-service's People

Contributors

caike avatar jonfriskics avatar

Stargazers

 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.