Giter Site home page Giter Site logo

greeting-web-service's Introduction


Greeting Web Service

Table of contents


Summary

Simple web service responding to requests with a greeting message. The service is written in Golang.

Getting Started

Clone the repository.
Follow the instructions to complete the installation.

Prerequisites

Packages

Tools

Features

  • Upon startup read the HTTP port to listen on from command line arguments and it uses a default value 8080 if command line argument is not specified. For example:
go run main.go --port=9999 #application will run on port 9999
go run main.go  #application will run on port 8080
  • The webservice have one end point (/greet) that accept POST request with JSON payload looking like this:
{
  "name" : "Sherif"
}

and it parses the JSON request and upon success respond with HTTP status 200 OK and a JSON body that looks like this:

{
  "message": "Hello Sherif!"
}
  • The webservice responses with HTTP status 405 (Method Not Allowed) if the request method on /greet is anything other than POST.
  • The webservice responses with HTTP status 400 (Bad Request) for any incorrect requests on the /greet endpoint (for example the payload is not valid JSON, the Content-Type header is not application/json or the name property is missing).
  • The webservice responses with HTTP status 404 (Not Found) on any URL other than /greet.
  • The service handles SIGINT or SIGTERM signals (kill command on Linux or Ctrl+C on both Windows and Linux) and exit gracefully.

UML Diagram

UML Diagram

Running

  • In your cloned directory.
  • open your terminal and run:
go run main.go

The server will start by default at:

You can specify port number by passing it as an argument:

go run main.go --port=9999 #application will run on port 9999

Logs

After running the server, logs.txt file will be created in the root directory of the project. It will contain the logs.

Postman collection

you will find the postman collection here.

You can get what is the right structure of JSON file to send requests and receiving responses from the postman collection after importing it in the Postman.

greeting-web-service's People

Contributors

marwangalal746 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.