Categorygithub.com/store-os/store-os-api
modulepackage
0.0.6-alpha
Repository: https://github.com/store-os/store-os-api.git
Documentation: pkg.go.dev

# README

store-os-api

API based in Go

Usage

Keep it simple

For those who wants keep it simple and avoid install a lot of things:

docker-compose up -d

Windows

docker run -v "C:/Hugo/themes/store-os/store-os-api/public/curl.sh:/work/curl.sh" -v "C:/Hugo/themes/store-os/store-os-api/public/test_search.json:/work/test_search.json" -v "C:/Hugo/themes/store-os/store-os-api/public/test_blog.json:/work/test_blog.json" -v "C:/Hugo/themes/store-os/store-os-api/public/search_template.json:/work/search_template.json" -it "ellerbrock/alpine-bash-curl-ssl" sh

Start using it

  1. Add comments to your API source code, See Declarative Comments Format.
  2. Download Swag for Go by using:
$ go get -u github.com/swaggo/swag/cmd/swag
  1. Run the Swag in your Go project root folder which contains main.go file, Swag will parse comments and generate required files(docs folder and docs/doc.go).
$ swag init
  1. Run Store OS API
$ go run main.go

Docker

brew install docker
docker network create localhost

Elasticsearch

docker run -d --network localhost --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.6.1

Elasticsearch will be located in localhost:9200

Cerebro

To monitor elasticsearch indexes

docker run -d --network localhost -p 9000:9000 --name cerebro yannart/cerebro:latest

Hit localhost:9000 in the browser to see the interface and enter http://elasticsearch:9200 to reach Elasticsearch

Kibana

To enter index mapping and to explore new queries/options in Elasticsearch

docker run --link 14833cb3405f:elasticsearch -p 5601:5601 --network localhost docker.elastic.co/kibana/kibana:7.6.1

Hit localhost:5601 in the browser to enter Kibana

API

docker build -t my-golang .
docker run -p 8080:8080 -e ELASTICSEARCH_URL="http://elasticsearch:9200" --network localhost my-golang
docker logs -f container_id

Site Example

  1. Index Template
curl \
  -H "Content-Type: application/json" \
  -XPUT "http://localhost:9200/_template/search_template" \
  --data-binary "@public/search_template.json"

or using Kibana to insert the index mapping

  1. Index search data
 curl \
  -H "Content-Type: application/x-ndjson" \
  -XPOST "http://localhost:9200/index_search/_bulk" \
  --data-binary "@public/test_search.json"
  1. Hit API
http://localhost:8080/search?q=home
http://localhost:8080/suggest?q=hom
http://localhost:8080/health

Autocomplete

Search as you type

Endpoints

Gin Tonic

Swagger

Gin Swagger

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author