Skip to content

eyuparslana/inStore

Repository files navigation

In Store

A rest-api that works with golang as an in-memory key value store

Usage

Fist of all, clone the repo with the command below. You must have golang installed on your computer to run the project.

git clone https://github.com/eyuparslana/inStore.git
  • Locally

Set the API_PORT, EXPORT_FILE_PATH and RECORD_FREQ environments. And run command below in terminal in project directory.

go run main.go

Now, you can send requests to the application either via postman, swagger or browser (GET requests only) according to the following endpoint table.

  • With Docker

If you have docker installed on your system, you can run the project with docker. Run command below on terminal.

docker-compose up -d

Now go to localhost:8001 in your browser. You will see the swagger page. Here you can send your requests to api.

or you can test the api on the URL below.

InStoreApp.

Endpoint Table

Endpoints Descriptions Methods cURL example
/ returns all data contained in DB in key value format. GET curl --location --request GET '<API_BASE_URL>:<API_PORT>/'
/set stores the key value in the JSON that comes with the POST request in the inMemDB key value format. POST curl --location --request POST '<API_BASE_URL>:<API_PORT>/set' --header 'Content-Type: application/json' --data-raw '{ "key": "computer", "value": "engineer"}'
/get Get returns the value corresponding to 'key' in DB. GET curl --location --request GET '<API_BASE_URL>:<API_PORT>/get?key=golang'
/flush Flush deletes all data in DB. DELETE curl --location --request DELETE '<API_BASE_URL>:<API_PORT>/flush'

About

In memory database rest-api example with golang

Resources

License

Stars

Watchers

Forks

Packages

No packages published