Categorygithub.com/Arcady1/OZON_Internship_API
modulepackage
0.0.0-20220409055047-a908b53e9783
Repository: https://github.com/arcady1/ozon_internship_api.git
Documentation: pkg.go.dev

# README

OZON INTERNSHIP REST API

Clone

  • Clone from GitHub:
$ git clone https://github.com/Arcady1/OZON_Internship_API.git
  • Prepare .env file:
PORT=8080

DB_HOST=127.0.0.1
DB_USER=<YOUR DB USER>
DB_PASSWORD=<YOUR PASSWORD>
DB_NAME=<YOUR DB NAME>
DB_SSLMODE=disable
DB_PORT=5432

Build and run

$ cd OZON_Internship_API/
$ go build -o app.bin
usage: ./app.bin l [local storage - default] 
usage: ./app.bin p [postgresql storage]

Server is listening on localhost: 8080

Test

$ go test -v

Docker

  • Clone the repository
  • Start docker:
$ docker-compose up --build

Server is listening on localhost: 8080

  • Stop docker:
$ docker-compose down

API

Get an original URL by short URL

Endpoint:

GET: http://127.0.0.1:8080/api/v1.0/url

Example request:

GET: http://127.0.0.1:8080/api/v1.0/url
?short=PBA4n_2n4s

Request parameters:

ParameterDescriptionRequired
shortThe short URL.True

The example of the response for the short PBA4n_2n4s

{
    "status": 200,
    "message": "Getting the original URL",
    "data": {
        "originalURL": "https://google.com"
    }
}

Response object:

PropertyDescription
statusThe status of the response.
messageStatus description.
data -> originalURLThe original URL.

Get a short URL by original URL

Endpoint:

POST: http://127.0.0.1:8080/api/v1.0/url

Example request:

POST: http://127.0.0.1:8080/api/v1.0/url
?original=https://google.com

Request parameters:

ParameterDescriptionRequired
originalThe original URL.True

The example of the response for the short https://google.com

{
    "status": 201,
    "message": "Original URL is saved",
    "data": {
        "shortURL": "PBA4n_2n4s"
    }
}

Response object:

PropertyDescription
statusThe status of the response.
messageStatus description.
data -> shortURLThe short URL.

# Packages

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

# Structs

No description provided by the author