Giter Club home page Giter Club logo

go-fetch-fask-server's Introduction

Go Report Card

FetchTaskServer

В проекте используется Nats для создания API. И mux для frontend API Для загрузки зависимостей используется Go modules Проект основывается на другом моём проекте.

Запуск

Запускать сначала докер для nats (см. ниже), потом запускаем /api/api.go Настройки api хранятся в settings.json, который должен находится в той же директории где запускается api.

Запросы

Название Запрос Описание
Загрузить ресурс в список элементов /v1/fetch в тело запроса передать json (стандарт RFC7159) формат см. ниже
Получение элемента /v1/get/{id} где id это id записи
Получение списка элементов /v1/list/
Удаление элемента /v1/delete/{id} где id это ид записи
Описание формата для запроса /v1/fetch

Оба поля в запросе обязательны, реализовано для метода GET, в Url не забывайте передавать адрес с указание протокола.

Запрос:

{"Method":"GET", "Url":"https://yandex.ru/"}

Ответ:

{
    "ID": "FiaIju1i",
    "StatusHttp": 200,
    "Headers": {
        "Content-Length": [
            "6799"
        ],
        "Content-Type": [
            "text/html; charset=utf-8"
        ],
        "Date": [
            "Sun, 31 Mar 2019 15:03:37 GMT"
        ],
        "Vary": [
            "Accept-Encoding"
        ],
        "Via": [
            "1.1 google"
        ],
        "X-Cloud-Trace-Context": [
            "774e384fcbe5fba78c97d996af237918/14559797058275749798;o=1"
        ]
    },
    "Length": 6799
}

Примечание: Для запросов при которых случилась какая то ошибка, к примеру нет элеметов для отображения, выводит ответ в след. формате:

{
   "Status": 404,
   "Description": "no element id: bDaYSlZX"
}

Запуск докера

Как установить и запустить Docker:

  1. Установка Docker-CE (ubuntu)
  2. Установка Docker compose
  3. sudo docker-compose up - запустится на 10000 порту

Файл настроек

Файл настроек используется формат json по RFC7159

Пример настроек settings.json:

{
  "name": "FetchTaskServer",
  "version": "1.0.0",
  "port" : "10000",
  "nats": {
    "version" : "1.4.2",
    "reconnectedWait" : 5,
    "address" : [
      {
        "host" : "localhost",
        "port" : "54222"
      },
      {
        "host" : "localhost",
        "port" : "54222"
      }
    ]
  }
}

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.