news-api

command module
v0.0.0-...-7854552 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2020 License: MIT Imports: 11 Imported by: 0

README

News API

Description

There are 2 main functions of these API as below:

  1. Publish a News by sending the news through message queue and then the worker consumer will store it into database and indexing
  2. Read all News with max 10 records per page sorted DESC by created from database and indexing

Endpoint

POST /v1/news
Request
curl --location --request POST 'http://localhost:50051/v1/news' \
--header 'Content-Type: application/json' \
--data-raw '{
    "author": "Author A",
    "body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent sapien mauris, viverra vel egestas sit amet, mattis sed libero. Etiam sed diam et felis venenatis porta. Aliquam semper sem eget lectus tristique vulputate.",
    "created": "2020-02-24T15:04:05Z"
}'
Response
{
  "data":null,
  "message":"News has been posted.",
  "success":true
}
GET /v1/news
Request
curl --location --request GET 'http://localhost:50051/v1/news?page=1'
Response
{
  "data":[
    {
      "id":2,
      "author":"Author B",
      "body":"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent sapien mauris, viverra vel egestas sit amet, mattis sed libero. Etiam sed diam et felis venenatis porta. Aliquam semper sem eget lectus tristique vulputate.",
      "created":"2020-02-25T15:04:05Z"
    },
    {
      "id":1,
      "author":"Author A",
      "body":"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent sapien mauris, viverra vel egestas sit amet, mattis sed libero. Etiam sed diam et felis venenatis porta. Aliquam semper sem eget lectus tristique vulputate.",
      "created":"2020-02-24T15:04:05Z"
    }
  ],
  "message":"",
  "success":true
}

Docker compose

docker-compose up --build

Heroku

https://bungysheep-news-api.herokuapp.com/

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL