Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vladimirlogachev/page-title-reader-microservice
Coding assessment (Scala 2, Akka HTTP) 2018
https://github.com/vladimirlogachev/page-title-reader-microservice
Last synced: 19 days ago
JSON representation
Coding assessment (Scala 2, Akka HTTP) 2018
- Host: GitHub
- URL: https://github.com/vladimirlogachev/page-title-reader-microservice
- Owner: vladimirlogachev
- Created: 2018-05-02T15:56:53.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2024-11-02T05:31:02.000Z (about 2 months ago)
- Last Synced: 2024-11-30T05:28:56.899Z (24 days ago)
- Language: Scala
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# page-title-reader-microservice
Coding assessment (Scala 2, Akka HTTP).
Completed in 2018, and currently maintained as a demonstration project.
## Pre-requisites
- [sbt](https://www.scala-sbt.org/)
## Usage
- `sbt run` - run
- `sbt styleFix` - fix formatting and linting errors
- `sbt styleCheck` - check for formatting and linting errors
- `sbt dev` - allow compiler warnings to not fail the compilation## What the microservice does
Give urls, get page titles
1. It gets page title for each of given url's in a list.
1. If URL is presented several times, it will be fetched once, but result will be printed several times, in the same order as in a source list.
1. It does not follow redirects immediately. Instead, it responds with a new location, so you can handle redirection before getting a final result.
1. It handles non-urls, empty strings, inaccessible hosts and http codes in a predictable mannerIt works well against cases like these:
```sh
curl -H 'Content-Type: application/json' \
-d '[
"https://ya.ru",
"www.dictionary.com/browse/http",
"https://api.github.com/",
"http://ya.ru",
"nonsense://yandex.ru",
"https://github.com/ladsgfadg",
"adsfgasdfg",
"",
"https://ya.ru"
]' \
-X POST \
http://localhost:8080```
... which result in:
```json
[
{ "url": "https://ya.ru", "title": "Яндекс — быстрый поиск в интернете" },
{
"url": "www.dictionary.com/browse/http",
"error": "Redirect: https://www.dictionary.com/browse/http"
},
{ "url": "https://api.github.com/", "error": "Page has no title" },
{ "url": "http://ya.ru", "error": "Redirect: https://ya.ru/" },
{ "url": "nonsense://yandex.ru", "error": "Bad url" },
{ "url": "https://github.com/ladsgfadg", "error": "Status code: 404" },
{ "url": "adsfgasdfg", "error": "Inaccessible host" },
{ "url": "", "error": "Inaccessible host" },
{ "url": "https://ya.ru", "title": "Яндекс — быстрый поиск в интернете" }
]
```