Skip to content

Commit

Permalink
reolve lint errors (#11)
Browse files Browse the repository at this point in the history
Signed-off-by: Vivek Kumar Sahu <vivekkumarsahu650@gmail.com>
  • Loading branch information
viveksahu26 committed Nov 27, 2023
1 parent 437be38 commit f521496
Showing 1 changed file with 28 additions and 23 deletions.
51 changes: 28 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# URL SHORTNER

[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/viveksahu26/url_shortner/badge)](https://securityscorecards.dev/viewer/?uri=github.com/viveksahu26/url_shortner)

**URL shortner endpoint - returns a short URL**

It is a service which takes long URL from the user and returns Short URL.
It is a service which takes long URL from the user and returns Short URL.
It provides 3 service.

1) health checks: it ensures that app is running.
Expand All @@ -15,68 +15,71 @@ Example: `http://localhost:8080/short-url?longURL=http://google.com/134646123456
3) long url : it takes short url and returns long url
Example: `http://localhost:8080/long-url?sortURL=xtNFxaBwCG`

## How URL Shortner Works !!
It replaces long URL by randomly generated characters of size 10.
## How URL Shortner Works

It replaces long URL by randomly generated characters of size 10.
It stores both Short and Long URL in the local file, `url.properties`.
If `url.properties` file is not present then creates new, otherwise write to the existing ones.
The advantage of saving Short URL and Long URL in the file is to retrieved that same Short URL correspondiing to Long URL.

The advantage of saving Short URL and Long URL in the file is to retrieved that same Short URL correspondiing to Long URL.

## Steps to reproduce it

1) Clone the repo:

`git clone https://github.com/viveksahu26/url_shortner.git`

2) Jump to the directory.

`cd url_shortner`

3) Execute main program.
3) Execute main program.

`go run main.go`

You can provide your custom port

`go run main.go 5000`

*NOTE:*: Make sure that Port 8080 is free. By defaul Port is 8080. But you can customize accordingly by passing port number after command(go run main.go).

4) Check the health of program

http://localhost:8080/health
<http://localhost:8080/health>

5) Convert longURL into ShortURL:

5) Convert longURL into ShortURL:

Enter your URL after *http://localhost:8080/sort-url?longURL=*
Enter your URL after *<http://localhost:8080/sort-url?longURL=>*

And let's say your Long URL: *http://google.com/1346461234567890123456789/get/viveksahu26*
And let's say your Long URL: *<http://google.com/1346461234567890123456789/get/viveksahu26>*

Finally you complete URL in the browser will look like:

http://localhost:8080/short-url?longURL=http://google.com/1346461234567890123456789/get/viveksahu26
<http://localhost:8080/short-url?longURL=http://google.com/1346461234567890123456789/get/viveksahu26>

http://localhost:8080/long-url?sortURL=xtNFxaBwCG
<http://localhost:8080/long-url?sortURL=xtNFxaBwCG>

You will get output

```
```
{"originalURL":"http://google.com/1346461234567890123456789/get/viveksahu26","shortURL":"http://localhost:8080/xtNFxaBwCG"}
```
```

6) Convert ShortURL into LongURL:

Let's say shortURL=xtNFxaBwCG

To get it's longURL enter below URL in the browser

http://localhost:8080/long-url?sortURL=xtNFxaBwCG

It will return longURL to you as:

http://google.com/1346461234567890123456789/get/viveksahu26

## Steps to reproduce Using Docker Image

### Step:1

Docker Image: viveksahu26/urlshortner:stable
Link: https://hub.docker.com/repository/docker/viveksahu26/urlshortner

Expand All @@ -85,6 +88,7 @@ Pull docker image:
docker pull viveksahu26/urlshortner:stable

### Step:2

Run container in non-interactive mode

docker run -d --name vivek -p 3000:8080 viveksahu26/urlshortner:stable
Expand All @@ -93,7 +97,8 @@ Run container in interactive mode

docker run --name vivek -p 3000:8080 viveksahu26/urlshortner:stable

### Step:3
### Step:3

Search on browser

http://localhost:3000/short-url?longURL=http://google.com/1346461234567890123456789/get/viveksahu26
Expand Down

0 comments on commit f521496

Please sign in to comment.