commit 506ee1714f1b071d4e6a401aa59818def64058be
Author: Omar Olivares <oaro@kth.se>
Date:   Sun May 26 23:03:22 2019 +0200

    Use wrapper in examples for README

diff --git a/README.md b/README.md
index 40e413d..ade7199 100644
--- a/README.md
+++ b/README.md
@@ -4,8 +4,8 @@ A reactive implementation of a URL minifier
 ### Build
 To build & run all tests \
-```mvn verify```
+```/.mvnw verify```
 
 You can also build a docker image by appending `jib:dockerBuild`\
-```mvn verify jib:dockerBuild```
+```/.mvnw verify jib:dockerBuild```
 
 ### Running the application

commit cf5e12152b4f65ab199f7cbab7542e22e7a6611e
Author: Omar Olivares <oaro@kth.se>
Date:   Sun May 26 23:00:37 2019 +0200

    Fix sentence for docker-compose in README

diff --git a/README.md b/README.md
index cb4d7d0..40e413d 100644
--- a/README.md
+++ b/README.md
@@ -18,5 +18,5 @@ If you want to run a docker container (after running `jib:dockerBuild`) \
 
-Or even easier with `docker-compose` if you don't feel like setting up redis (after running `jib:dockerBuild`) \
+Or even easier with `docker-compose` if you don't feel like setting up redis  \
 ```docker-compose up```
 
 ### Usage

commit 8bb4b2be706a553fdd96f74af0305dc6d0f1bb2e
Author: Omar Olivares <oaro@kth.se>
Date:   Sun May 26 22:59:41 2019 +0200

    Fix unnecessary trailing slash in README

diff --git a/README.md b/README.md
index 028004b..cb4d7d0 100644
--- a/README.md
+++ b/README.md
@@ -24,3 +24,3 @@ This section assumes you are running MiniUrl locally on port `8080`
 
-To hash a URL \
+To hash a URL
 ```

commit fadff9ae5ea077fb61bbfa6dbf15c42b5a836294
Author: Omar Olivares <oaro@kth.se>
Date:   Sun May 26 22:57:59 2019 +0200

    Updated readme

diff --git a/README.md b/README.md
index ed9b0b6..028004b 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,11 @@
 # MiniUrl
 A reactive implementation of a URL minifier
 
-
 ### Build
 To build & run all tests \
-  `mvn verify`
+```mvn verify```
 
 You can also build a docker image by appending `jib:dockerBuild`\
-`mvn verify jib:dockerBuild`
+```mvn verify jib:dockerBuild```
 
 ### Running the application
@@ -14,10 +13,10 @@ MiniUrl requires a Redis server running locally on port `6379`
 To run the application after just building \
-`java -jar target/miniurl-0.0.1-SNAPSHOT.jar` 
+```java -jar target/miniurl-0.0.1-SNAPSHOT.jar```
 
 If you want to run a docker container (after running `jib:dockerBuild`) \
-`docker run -p 8080:8080 -t miniurl:latest`
+```docker run -p 8080:8080 -t miniurl:latest```
 
 Or even easier with `docker-compose` if you don't feel like setting up redis (after running `jib:dockerBuild`) \
-`docker-compose up`
+```docker-compose up```
 
 ### Usage

commit 81f04c98333f5aac84b63cf0f1f0226e47a12689
Author: Omar Olivares <oaro@kth.se>
Date:   Sun May 26 22:56:33 2019 +0200

    Updated readme

diff --git a/README.md b/README.md
index 85daf0e..ed9b0b6 100644
--- a/README.md
+++ b/README.md
@@ -2 +2,59 @@
 A reactive implementation of a URL minifier
+
+
+### Build
+To build & run all tests \
+  `mvn verify`
+
+You can also build a docker image by appending `jib:dockerBuild`\
+`mvn verify jib:dockerBuild`
+
+### Running the application
+MiniUrl requires a Redis server running locally on port `6379`
+To run the application after just building \
+`java -jar target/miniurl-0.0.1-SNAPSHOT.jar` 
+
+If you want to run a docker container (after running `jib:dockerBuild`) \
+`docker run -p 8080:8080 -t miniurl:latest`
+
+Or even easier with `docker-compose` if you don't feel like setting up redis (after running `jib:dockerBuild`) \
+`docker-compose up`
+
+### Usage
+This section assumes you are running MiniUrl locally on port `8080` 
+
+To hash a URL \
+```
+curl --header "Content-Type: application/json" \
+      --request POST \
+      --data '{"url":"www.google.com"}' \
+localhost:8080/
+
+{
+  "hash":"08316aaa"
+}
+``` 
+If you wish to set a custom ttl on your about-to-be minified url, see following json
+```json
+{
+  "url":"www.google.com",
+  "ttl": 15000
+}
+```
+where `ttl` is expressed in milliseconds
+
+Calling the API with the hash
+```
+curl localhost:8080/08316aaa
+
+...
+< HTTP/1.1 302 Found
+< Location: www.google.com
+< content-length: 0
+...
+```
+
+
+
+
+

commit db47904e18ddb269e8b013fc03d4e6706dd29f56
Author: Omar Olivares <oaro@kth.se>
Date:   Sun May 26 22:03:00 2019 +0200

    Fix tests

diff --git a/src/main/java/io/github/miniurl/urlshortener/UrlShortenerService.java b/src/main/java/io/github/miniurl/urlshortener/UrlShortenerService.java
index 88d3cec..b13eef4 100644
--- a/src/main/java/io/github/miniurl/urlshortener/UrlShortenerService.java
+++ b/src/main/java/io/github/miniurl/urlshortener/UrlShortenerService.java
@@ -14,41 +14,47 @@ import static org.valid4j.Assertive.require;
 @Service
 public class UrlShortenerService {
     //ttl is enforced, so we'll need to define a default TTL
     public final static Duration DEFAULT_TTL = Duration.ofDays(365 * 2); //approx...
     private final Hasher hasher;
     private final UrlRepository urlRepository;
 
     @Autowired
     public UrlShortenerService(Hasher hasher, UrlRepository urlRepository) {
         this.hasher = require(hasher, notNullValue());
         this.urlRepository = require(urlRepository, notNullValue());
     }
 
     /**
      * Hashes & stores a URL wrapped in a UrlRequestBody. Will normalize the URL
      * to reduce "duplicate" urls that may differ but point to same location.
      * TTL is optional but will use a default TTL of ~2 years if not provided.
      *
      * @param urlRequestBody Request body of a url to be hashed
      * @return A domain object representing the hashed url
      */
     public Mono<ShortenedUrl> hashUrl(UrlRequestBody urlRequestBody) {
         URI normalizedUrl = urlRequestBody.getUrl()
                                           .normalize();
         String hashedUrl = hasher.hash(normalizedUrl);
 
         Duration ttl = urlRequestBody.getTtl()
                                      .map(Duration::ofMillis)
                                      .orElse(DEFAULT_TTL);
 
         return urlRepository.store(new ShortenedUrl(normalizedUrl, hashedUrl, ttl))
                             .log()
                             .onErrorMap(throwable -> new UrlShortenerException("Failed to store hashed URL", throwable));
     }
 
+    /**
+     * Returns a URL by providing a hash, triggering a lookup in the persistent data store
+     *
+     * @param hash Hash generated when calling hashUrl()
+     * @return A mono that may or may not contain an URI
+     */
     public Mono<URI> getUri(String hash) {
         return Mono.just(hash)
                    .log()
                    .flatMap(urlRepository::fetch);
     }
 }
diff --git a/src/test/java/io/github/miniurl/it/MiniUrlCreateIT.java b/src/test/java/io/github/miniurl/it/MiniUrlCreateIT.java
index 8dbd660..e3d4b1d 100644
--- a/src/test/java/io/github/miniurl/it/MiniUrlCreateIT.java
+++ b/src/test/java/io/github/miniurl/it/MiniUrlCreateIT.java
@@ -21,36 +21,36 @@ import static org.valid4j.matchers.ArgumentMatchers.notEmptyString;
 @AutoConfigureWebTestClient
 public class MiniUrlCreateIT extends BaseIT {
     @Autowired
     private WebTestClient webClient;
 
     @Autowired
     private ReactiveRedisTemplate<String, String> redisTemplate;
 
     @Test
     public void shouldCreateHashedUrl() {
         final URI uri = URI.create("www.google.com");
 
-        final UrlRequestBody request = new UrlRequestBody(uri, Optional.of(15_000L));
+        final UrlRequestBody request = new UrlRequestBody(uri, 15_000L);
 
         UrlResponseBody result = webClient.post()
                                           .uri("/")
                                           .contentType(MediaType.APPLICATION_JSON)
                                           .body(BodyInserters.fromObject(request))
                                           .exchange()
                                           .expectStatus().isOk()
                                           .returnResult(UrlResponseBody.class)
                                           .getResponseBody()
                                           .blockFirst();
 
         //Verify response
         assertThat(result, notNullValue());
         assertThat(result.getHash(), notEmptyString());
 
         //Verify state in redis
         URI actualOriginalUri = redisTemplate.opsForValue()
                                              .get(result.getHash())
                                              .map(URI::create)
                                              .block();
         assertThat(actualOriginalUri, equalTo(uri));
     }
 }
diff --git a/src/test/java/io/github/miniurl/urlshortener/UrlShortenerServiceTest.java b/src/test/java/io/github/miniurl/urlshortener/UrlShortenerServiceTest.java
index 85fa6b1..4a6ec0f 100644
--- a/src/test/java/io/github/miniurl/urlshortener/UrlShortenerServiceTest.java
+++ b/src/test/java/io/github/miniurl/urlshortener/UrlShortenerServiceTest.java
@@ -19,53 +19,53 @@ import static org.mockito.ArgumentMatchers.eq;
 public class UrlShortenerServiceTest {
     private final static URI DEFAULT_URI = URI.create("www.google.com");
     private Hasher hasher;
     private UrlRepository urlRepository;
 
     @Before
     public void setup() {
         hasher = Mockito.mock(Hasher.class);
         urlRepository = Mockito.mock(UrlRepository.class);
 
         Mockito.when(hasher.hash(any())).thenReturn("hash");
         Mockito.when(urlRepository.store(any()))
                .thenAnswer(invocation -> Mono.just(invocation.getArgument(0))); //echo back same response
         Mockito.when(urlRepository.fetch(eq("hash")))
                .thenReturn(Mono.just(URI.create("www.google.com")));
     }
 
     @Test
     public void shouldCreateValidShortenedUrl() {
 
         UrlShortenerService urlShortenerService = new UrlShortenerService(hasher, urlRepository);
-        ShortenedUrl shortenedUrl = urlShortenerService.hashUrl(new UrlRequestBody(DEFAULT_URI, Optional.empty()))
+        ShortenedUrl shortenedUrl = urlShortenerService.hashUrl(new UrlRequestBody(DEFAULT_URI, null))
                                                        .block();
 
         assertThat(shortenedUrl, notNullValue());
         assertThat(shortenedUrl.getHashedUrl(), equalTo("hash"));
         assertThat(shortenedUrl.getOriginalUrl(), equalTo(DEFAULT_URI));
         assertThat(shortenedUrl.getTtl(), equalTo(UrlShortenerService.DEFAULT_TTL));
     }
 
     @Test
     public void shouldCreateValidShortenedUrlWithProvidedTtl() {
         final Long ttl = Duration.ofHours(5).toMillis();
 
         UrlShortenerService urlShortenerService = new UrlShortenerService(hasher, urlRepository);
-        ShortenedUrl shortenedUrl = urlShortenerService.hashUrl(new UrlRequestBody(DEFAULT_URI, Optional.of(ttl)))
+        ShortenedUrl shortenedUrl = urlShortenerService.hashUrl(new UrlRequestBody(DEFAULT_URI, ttl))
                                                        .block();
 
         assertThat(shortenedUrl, notNullValue());
         assertThat(shortenedUrl.getHashedUrl(), equalTo("hash"));
         assertThat(shortenedUrl.getOriginalUrl(), equalTo(DEFAULT_URI));
         assertThat(shortenedUrl.getTtl(), equalTo(Duration.ofMillis(ttl)));
     }
 
     @Test
     public void shouldGetValidUrl() {
         UrlShortenerService urlShortenerService = new UrlShortenerService(hasher, urlRepository);
         URI result = urlShortenerService.getUri("hash")
                                         .block();
 
         assertThat(result, equalTo(DEFAULT_URI));
     }
 }
\ No newline at end of file

commit cebda63bf5d0c6b5271fb60182ba9a7bd57c86f5
Author: Omar Olivares <oaro@kth.se>
Date:   Sun May 26 21:55:32 2019 +0200

    Explicit getter for ttl to resolve issue with optional itself being null

diff --git a/src/main/java/io/github/miniurl/api/UrlRequestBody.java b/src/main/java/io/github/miniurl/api/UrlRequestBody.java
index cdaefd5..18d875c 100644
--- a/src/main/java/io/github/miniurl/api/UrlRequestBody.java
+++ b/src/main/java/io/github/miniurl/api/UrlRequestBody.java
@@ -12,9 +12,14 @@ import java.util.Optional;
 @Data
 @NoArgsConstructor
 @AllArgsConstructor
 public class UrlRequestBody {
     @NotNull
     private URI url;
 
-    private Optional<@Positive Long> ttl;
+    @Positive
+    private Long ttl;
+
+    public Optional<Long> getTtl() {
+        return Optional.ofNullable(ttl);
+    }
 }

commit 0c6b507ad3216fdf86ef827bb97b6ff34f36dd3f
Author: Omar Olivares <oaro@kth.se>
Date:   Sun May 26 21:48:03 2019 +0200

    Add docker config & docker-compose.

diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..fcf7a3b
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,28 @@
+version: '3'
+
+services:
+  miniurl:
+    image: miniurl:latest
+    ports:
+      - "8080:8080"
+    networks:
+      - redis-net
+    depends_on:
+      - redis
+    environment:
+      - "SPRING_PROFILES_ACTIVE=docker"
+
+  redis:
+    image: redis:5.0.5
+    command: ["redis-server", "--appendonly", "yes"]
+    hostname: redis
+    networks:
+      - redis-net
+    volumes:
+      - redis-data:/data
+
+networks:
+  redis-net:
+
+volumes:
+  redis-data:
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index f24ae8a..d16c476 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,84 +1,94 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
         <version>2.1.5.RELEASE</version>
         <relativePath/> <!-- lookup parent from repository -->
     </parent>
     <groupId>io.github</groupId>
     <artifactId>miniurl</artifactId>
     <version>0.0.1-SNAPSHOT</version>
     <name>miniurl</name>
     <description>Demo project for Spring Boot</description>
 
     <properties>
         <java.version>11</java.version>
     </properties>
 
     <dependencies>
 
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-data-redis-reactive</artifactId>
         </dependency>
 
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-webflux</artifactId>
         </dependency>
 
         <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
         <dependency>
             <groupId>org.projectlombok</groupId>
             <artifactId>lombok</artifactId>
             <version>1.18.0</version>
             <scope>provided</scope>
         </dependency>
 
         <!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
         <dependency>
             <groupId>com.google.guava</groupId>
             <artifactId>guava</artifactId>
             <version>27.1-jre</version>
         </dependency>
 
         <dependency>
             <groupId>org.valid4j</groupId>
             <artifactId>valid4j</artifactId>
             <version>0.5.0</version>
         </dependency>
 
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-test</artifactId>
             <scope>test</scope>
         </dependency>
 
         <dependency>
             <groupId>io.projectreactor</groupId>
             <artifactId>reactor-test</artifactId>
             <scope>test</scope>
         </dependency>
 
         <dependency>
             <groupId>org.testcontainers</groupId>
             <artifactId>testcontainers</artifactId>
             <version>1.11.2</version>
             <scope>test</scope>
         </dependency>
 
     </dependencies>
 
     <build>
         <plugins>
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
             </plugin>
+            <plugin>
+                <groupId>com.google.cloud.tools</groupId>
+                <artifactId>jib-maven-plugin</artifactId>
+                <version>1.2.0</version>
+                <configuration>
+                    <to>
+                        <image>miniurl</image>
+                    </to>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
 
 </project>
diff --git a/src/main/java/io/github/miniurl/MiniUrlApplication.java b/src/main/java/io/github/miniurl/MiniUrlApplication.java
index 7f47d87..ddb500f 100644
--- a/src/main/java/io/github/miniurl/MiniUrlApplication.java
+++ b/src/main/java/io/github/miniurl/MiniUrlApplication.java
@@ -11,15 +11,14 @@ import org.springframework.data.redis.serializer.RedisSerializationContext;
 @SpringBootApplication
 @Configuration
 public class MiniUrlApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(MiniUrlApplication.class, args);
     }
 
     @Bean
     public ReactiveRedisTemplate<String, String> reactiveRedisTemplateString
             (ReactiveRedisConnectionFactory connectionFactory) {
         return new ReactiveRedisTemplate<>(connectionFactory, RedisSerializationContext.string());
     }
-
 }
diff --git a/src/main/resources/application-docker.yml b/src/main/resources/application-docker.yml
new file mode 100644
index 0000000..5b568da
--- /dev/null
+++ b/src/main/resources/application-docker.yml
@@ -0,0 +1,3 @@
+spring:
+  redis:
+    url: redis://:@redis:6379
\ No newline at end of file
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 694d066..47fbb02 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -1,5 +1,2 @@
 server:
-  port: 8080
-
-miniurl:
-  base-url: localhost:8080
\ No newline at end of file
+  port: 8080
\ No newline at end of file

commit b30989442f1cc43e10b1caa27e0dc53ba96c0fa6
Author: Omar Olivares <oaro@kth.se>
Date:   Sun May 26 20:27:04 2019 +0200

    Implement fetch uri. Add appropriate tests

diff --git a/src/main/java/io/github/miniurl/controllers/UrlController.java b/src/main/java/io/github/miniurl/controllers/UrlController.java
index b0a1733..181430c 100644
--- a/src/main/java/io/github/miniurl/controllers/UrlController.java
+++ b/src/main/java/io/github/miniurl/controllers/UrlController.java
@@ -5,6 +5,7 @@ import io.github.miniurl.api.UrlResponseBody;
 import io.github.miniurl.urlshortener.UrlShortenerService;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
 import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
 import reactor.core.publisher.Mono;
@@ -12,2 +13,4 @@ import reactor.core.publisher.Mono;
 import javax.validation.Valid;
+import javax.validation.constraints.NotBlank;
+import java.net.URI;
 
@@ -17,14 +20,27 @@ import static org.valid4j.Assertive.require;
 @RestController
 public class UrlController {
     private final UrlShortenerService urlShortener;
 
     public UrlController(UrlShortenerService urlShortener) {
         this.urlShortener = require(urlShortener, notNullValue());
     }
 
     @PostMapping(produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
     public Mono<UrlResponseBody> hashUrl(@RequestBody @Valid UrlRequestBody request) {
         return urlShortener.hashUrl(request)
                            .map(shortenedUrl -> new UrlResponseBody(shortenedUrl.getHashedUrl()));
     }
+
+    @GetMapping("/{hash}")
+    public Mono<ResponseEntity<Void>> lookup(@NotBlank @PathVariable("hash") String hash) {
+        return urlShortener.getUri(hash)
+                           .flatMap(uri -> Mono.just(found(uri)))
+                           .switchIfEmpty(Mono.just(new ResponseEntity<Void>(HttpStatus.NOT_FOUND)));
+    }
+
+    private ResponseEntity<Void> found(URI uri) {
+        HttpHeaders httpHeaders = new HttpHeaders();
+        httpHeaders.setLocation(uri);
+        return new ResponseEntity<>(httpHeaders, HttpStatus.FOUND);
+    }
 }
diff --git a/src/main/java/io/github/miniurl/urlshortener/UrlRepository.java b/src/main/java/io/github/miniurl/urlshortener/UrlRepository.java
index 3f0df4b..2e9f716 100644
--- a/src/main/java/io/github/miniurl/urlshortener/UrlRepository.java
+++ b/src/main/java/io/github/miniurl/urlshortener/UrlRepository.java
@@ -8,2 +8,4 @@ import reactor.core.publisher.Mono;
 
+import java.net.URI;
+
 import static org.hamcrest.core.IsNull.notNullValue;
@@ -12,15 +14,21 @@ import static org.valid4j.Assertive.require;
 @Repository
 public class UrlRepository {
     private final ReactiveRedisTemplate<String, String> redisTemplate;
 
     @Autowired
     public UrlRepository(ReactiveRedisTemplate<String, String> redisTemplate) {
         this.redisTemplate = require(redisTemplate, notNullValue());
     }
 
     public Mono<ShortenedUrl> store(ShortenedUrl shortenedUrl) {
         return redisTemplate.opsForValue()
                             .set(shortenedUrl.getHashedUrl(), shortenedUrl.getOriginalUrl().toString(), shortenedUrl.getTtl())
                             .then(Mono.just(shortenedUrl));
     }
+
+    public Mono<URI> fetch(String hash) {
+        return redisTemplate.opsForValue()
+                            .get(hash)
+                            .map(URI::create);
+    }
 }
diff --git a/src/main/java/io/github/miniurl/urlshortener/UrlShortenerService.java b/src/main/java/io/github/miniurl/urlshortener/UrlShortenerService.java
index e16e040..88d3cec 100644
--- a/src/main/java/io/github/miniurl/urlshortener/UrlShortenerService.java
+++ b/src/main/java/io/github/miniurl/urlshortener/UrlShortenerService.java
@@ -14,35 +14,41 @@ import static org.valid4j.Assertive.require;
 @Service
 public class UrlShortenerService {
     //ttl is enforced, so we'll need to define a default TTL
     public final static Duration DEFAULT_TTL = Duration.ofDays(365 * 2); //approx...
     private final Hasher hasher;
     private final UrlRepository urlRepository;
 
     @Autowired
     public UrlShortenerService(Hasher hasher, UrlRepository urlRepository) {
         this.hasher = require(hasher, notNullValue());
         this.urlRepository = require(urlRepository, notNullValue());
     }
 
     /**
      * Hashes & stores a URL wrapped in a UrlRequestBody. Will normalize the URL
      * to reduce "duplicate" urls that may differ but point to same location.
      * TTL is optional but will use a default TTL of ~2 years if not provided.
      *
      * @param urlRequestBody Request body of a url to be hashed
      * @return A domain object representing the hashed url
      */
     public Mono<ShortenedUrl> hashUrl(UrlRequestBody urlRequestBody) {
         URI normalizedUrl = urlRequestBody.getUrl()
                                           .normalize();
         String hashedUrl = hasher.hash(normalizedUrl);
 
         Duration ttl = urlRequestBody.getTtl()
                                      .map(Duration::ofMillis)
                                      .orElse(DEFAULT_TTL);
 
         return urlRepository.store(new ShortenedUrl(normalizedUrl, hashedUrl, ttl))
                             .log()
                             .onErrorMap(throwable -> new UrlShortenerException("Failed to store hashed URL", throwable));
     }
+
+    public Mono<URI> getUri(String hash) {
+        return Mono.just(hash)
+                   .log()
+                   .flatMap(urlRepository::fetch);
+    }
 }
diff --git a/src/test/java/io/github/miniurl/it/MiniUrlFetchIT.java b/src/test/java/io/github/miniurl/it/MiniUrlFetchIT.java
new file mode 100644
index 0000000..8789a72
--- /dev/null
+++ b/src/test/java/io/github/miniurl/it/MiniUrlFetchIT.java
@@ -0,0 +1,46 @@
+package io.github.miniurl.it;
+
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient;
+import org.springframework.data.redis.core.ReactiveRedisTemplate;
+import org.springframework.http.HttpHeaders;
+import org.springframework.test.web.reactive.server.WebTestClient;
+
+import java.net.URI;
+
+import static java.lang.String.format;
+import static org.hamcrest.core.IsEqual.equalTo;
+
+@AutoConfigureWebTestClient
+public class MiniUrlFetchIT extends BaseIT {
+    @Autowired
+    private WebTestClient webClient;
+
+    @Autowired
+    private ReactiveRedisTemplate<String, String> redisTemplate;
+
+    @Test
+    public void shouldFetchOriginalUrl() {
+        final URI uri = URI.create("www.google.com");
+        final String hash = "abc123";
+        //setup state in redis
+        redisTemplate.opsForValue()
+                     .set(hash, uri.toString())
+                     .block();
+
+        webClient.get()
+                 .uri(format("/%s", hash))
+                 .exchange()
+                 .expectStatus().isFound()
+                 .expectHeader().value(HttpHeaders.LOCATION, equalTo(uri.toString()));
+    }
+
+    @Test
+    public void shouldFailFetchingOriginalUrl() {
+        webClient.get()
+                 .uri("/does-not-exist")
+                 .exchange()
+                 .expectStatus().isNotFound();
+    }
+}
diff --git a/src/test/java/io/github/miniurl/urlshortener/UrlShortenerServiceTest.java b/src/test/java/io/github/miniurl/urlshortener/UrlShortenerServiceTest.java
index 1c77fc0..85fa6b1 100644
--- a/src/test/java/io/github/miniurl/urlshortener/UrlShortenerServiceTest.java
+++ b/src/test/java/io/github/miniurl/urlshortener/UrlShortenerServiceTest.java
@@ -16,46 +16,56 @@ import static org.hamcrest.core.IsNull.notNullValue;
 import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
 
 public class UrlShortenerServiceTest {
+    private final static URI DEFAULT_URI = URI.create("www.google.com");
     private Hasher hasher;
     private UrlRepository urlRepository;
 
     @Before
     public void setup() {
         hasher = Mockito.mock(Hasher.class);
         urlRepository = Mockito.mock(UrlRepository.class);
 
         Mockito.when(hasher.hash(any())).thenReturn("hash");
         Mockito.when(urlRepository.store(any()))
                .thenAnswer(invocation -> Mono.just(invocation.getArgument(0))); //echo back same response
+        Mockito.when(urlRepository.fetch(eq("hash")))
+               .thenReturn(Mono.just(URI.create("www.google.com")));
     }
 
     @Test
     public void shouldCreateValidShortenedUrl() {
-        final URI uri = URI.create("www.google.com");
 
         UrlShortenerService urlShortenerService = new UrlShortenerService(hasher, urlRepository);
-        ShortenedUrl shortenedUrl = urlShortenerService.hashUrl(new UrlRequestBody(uri, Optional.empty()))
+        ShortenedUrl shortenedUrl = urlShortenerService.hashUrl(new UrlRequestBody(DEFAULT_URI, Optional.empty()))
                                                        .block();
 
         assertThat(shortenedUrl, notNullValue());
         assertThat(shortenedUrl.getHashedUrl(), equalTo("hash"));
-        assertThat(shortenedUrl.getOriginalUrl(), equalTo(uri));
+        assertThat(shortenedUrl.getOriginalUrl(), equalTo(DEFAULT_URI));
         assertThat(shortenedUrl.getTtl(), equalTo(UrlShortenerService.DEFAULT_TTL));
     }
 
-
     @Test
     public void shouldCreateValidShortenedUrlWithProvidedTtl() {
-        final URI uri = URI.create("www.google.com");
         final Long ttl = Duration.ofHours(5).toMillis();
 
         UrlShortenerService urlShortenerService = new UrlShortenerService(hasher, urlRepository);
-        ShortenedUrl shortenedUrl = urlShortenerService.hashUrl(new UrlRequestBody(uri, Optional.of(ttl)))
+        ShortenedUrl shortenedUrl = urlShortenerService.hashUrl(new UrlRequestBody(DEFAULT_URI, Optional.of(ttl)))
                                                        .block();
 
         assertThat(shortenedUrl, notNullValue());
         assertThat(shortenedUrl.getHashedUrl(), equalTo("hash"));
-        assertThat(shortenedUrl.getOriginalUrl(), equalTo(uri));
+        assertThat(shortenedUrl.getOriginalUrl(), equalTo(DEFAULT_URI));
         assertThat(shortenedUrl.getTtl(), equalTo(Duration.ofMillis(ttl)));
     }
+
+    @Test
+    public void shouldGetValidUrl() {
+        UrlShortenerService urlShortenerService = new UrlShortenerService(hasher, urlRepository);
+        URI result = urlShortenerService.getUri("hash")
+                                        .block();
+
+        assertThat(result, equalTo(DEFAULT_URI));
+    }
 }
\ No newline at end of file

commit a3343a7678fb99aac1c55113ccd5b680e339dd75
Author: Omar Olivares <oaro@kth.se>
Date:   Sun May 26 19:11:50 2019 +0200

    Only return hash, let client decide how to construct url

diff --git a/src/main/java/io/github/miniurl/api/UrlResponseBody.java b/src/main/java/io/github/miniurl/api/UrlResponseBody.java
index 68c6dd8..2555155 100644
--- a/src/main/java/io/github/miniurl/api/UrlResponseBody.java
+++ b/src/main/java/io/github/miniurl/api/UrlResponseBody.java
@@ -6,9 +6,7 @@ import lombok.NoArgsConstructor;
 
-import java.net.URI;
-
 @Data
 @AllArgsConstructor
 @NoArgsConstructor
 public class UrlResponseBody {
-    private URI url;
+    private String hash;
 }
diff --git a/src/main/java/io/github/miniurl/controllers/UrlController.java b/src/main/java/io/github/miniurl/controllers/UrlController.java
index 31bc3ac..b0a1733 100644
--- a/src/main/java/io/github/miniurl/controllers/UrlController.java
+++ b/src/main/java/io/github/miniurl/controllers/UrlController.java
@@ -6,3 +6,2 @@ import io.github.miniurl.urlshortener.UrlShortenerService;
 import org.springframework.http.MediaType;
-import org.springframework.http.server.reactive.ServerHttpRequest;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -10,3 +9,2 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.util.UriComponentsBuilder;
 import reactor.core.publisher.Mono;
@@ -14,3 +12,2 @@ import reactor.core.publisher.Mono;
 import javax.validation.Valid;
-import java.net.URI;
 
@@ -20,28 +17,14 @@ import static org.valid4j.Assertive.require;
 @RestController
 public class UrlController {
     private final UrlShortenerService urlShortener;
 
     public UrlController(UrlShortenerService urlShortener) {
         this.urlShortener = require(urlShortener, notNullValue());
     }
 
     @PostMapping(produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
-    public Mono<UrlResponseBody> hashUrl(@RequestBody @Valid UrlRequestBody request,
-                                         ServerHttpRequest serverRequest) {
+    public Mono<UrlResponseBody> hashUrl(@RequestBody @Valid UrlRequestBody request) {
         return urlShortener.hashUrl(request)
-                           .map(shortenedUrl -> generateResponseUrl(shortenedUrl.getHashedUrl(), serverRequest))
-                           .map(UrlResponseBody::new);
-    }
-
-    //Construct baseUri from request-uri. Spring should in most cases
-    //be able to infer from the http request the proper request URI
-    private URI generateResponseUrl(String pathValue, ServerHttpRequest serverRequest) {
-        URI requestUri = serverRequest.getURI();
-
-        return UriComponentsBuilder.fromUri(requestUri)
-                                   .replacePath(pathValue)
-                                   .replaceQuery(null)
-                                   .build()
-                                   .toUri();
+                           .map(shortenedUrl -> new UrlResponseBody(shortenedUrl.getHashedUrl()));
     }
 }
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
deleted file mode 100644
index 8b13789..0000000
--- a/src/main/resources/application.properties
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
new file mode 100644
index 0000000..694d066
--- /dev/null
+++ b/src/main/resources/application.yml
@@ -0,0 +1,5 @@
+server:
+  port: 8080
+
+miniurl:
+  base-url: localhost:8080
\ No newline at end of file
diff --git a/src/test/java/io/github/miniurl/it/MiniUrlCreateIT.java b/src/test/java/io/github/miniurl/it/MiniUrlCreateIT.java
index c0f761a..8dbd660 100644
--- a/src/test/java/io/github/miniurl/it/MiniUrlCreateIT.java
+++ b/src/test/java/io/github/miniurl/it/MiniUrlCreateIT.java
@@ -8,5 +8,5 @@ import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWeb
 import org.springframework.data.redis.core.ReactiveRedisTemplate;
+import org.springframework.http.MediaType;
 import org.springframework.test.web.reactive.server.WebTestClient;
 import org.springframework.web.reactive.function.BodyInserters;
-import reactor.core.publisher.Mono;
 
@@ -18,37 +18,39 @@ import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.IsNull.notNullValue;
+import static org.valid4j.matchers.ArgumentMatchers.notEmptyString;
 
 @AutoConfigureWebTestClient
 public class MiniUrlCreateIT extends BaseIT {
-
     @Autowired
     private WebTestClient webClient;
 
     @Autowired
     private ReactiveRedisTemplate<String, String> redisTemplate;
 
     @Test
     public void shouldCreateHashedUrl() {
         final URI uri = URI.create("www.google.com");
+
         final UrlRequestBody request = new UrlRequestBody(uri, Optional.of(15_000L));
 
         UrlResponseBody result = webClient.post()
                                           .uri("/")
+                                          .contentType(MediaType.APPLICATION_JSON)
                                           .body(BodyInserters.fromObject(request))
                                           .exchange()
                                           .expectStatus().isOk()
                                           .returnResult(UrlResponseBody.class)
                                           .getResponseBody()
                                           .blockFirst();
 
         //Verify response
         assertThat(result, notNullValue());
-        assertThat(result.getUrl(), notNullValue());
+        assertThat(result.getHash(), notEmptyString());
 
         //Verify state in redis
         URI actualOriginalUri = redisTemplate.opsForValue()
-                                             .get(result.getUrl().getPath())
+                                             .get(result.getHash())
                                              .map(URI::create)
                                              .block();
         assertThat(actualOriginalUri, equalTo(uri));
     }
 }

commit 9213138d6a300d30e77f952816bce62f3edbfa56
Author: Omar Olivares <oaro@kth.se>
Date:   Sun May 26 15:52:07 2019 +0200

    (Cont.) Add missing tests

diff --git a/src/test/java/io/github/miniurl/it/MiniUrlCreateIT.java b/src/test/java/io/github/miniurl/it/MiniUrlCreateIT.java
index 3a49fd0..c0f761a 100644
--- a/src/test/java/io/github/miniurl/it/MiniUrlCreateIT.java
+++ b/src/test/java/io/github/miniurl/it/MiniUrlCreateIT.java
@@ -20,34 +20,35 @@ import static org.hamcrest.core.IsNull.notNullValue;
 @AutoConfigureWebTestClient
 public class MiniUrlCreateIT extends BaseIT {
 
     @Autowired
     private WebTestClient webClient;
 
     @Autowired
     private ReactiveRedisTemplate<String, String> redisTemplate;
 
     @Test
     public void shouldCreateHashedUrl() {
         final URI uri = URI.create("www.google.com");
         final UrlRequestBody request = new UrlRequestBody(uri, Optional.of(15_000L));
 
         UrlResponseBody result = webClient.post()
                                           .uri("/")
                                           .body(BodyInserters.fromObject(request))
                                           .exchange()
                                           .expectStatus().isOk()
                                           .returnResult(UrlResponseBody.class)
                                           .getResponseBody()
                                           .blockFirst();
+
         //Verify response
         assertThat(result, notNullValue());
         assertThat(result.getUrl(), notNullValue());
 
         //Verify state in redis
         URI actualOriginalUri = redisTemplate.opsForValue()
                                              .get(result.getUrl().getPath())
                                              .map(URI::create)
                                              .block();
         assertThat(actualOriginalUri, equalTo(uri));
     }
 }
diff --git a/src/test/java/io/github/miniurl/urlshortener/UrlShortenerServiceTest.java b/src/test/java/io/github/miniurl/urlshortener/UrlShortenerServiceTest.java
index 1aab8ea..1c77fc0 100644
--- a/src/test/java/io/github/miniurl/urlshortener/UrlShortenerServiceTest.java
+++ b/src/test/java/io/github/miniurl/urlshortener/UrlShortenerServiceTest.java
@@ -9,2 +9,3 @@ import reactor.core.publisher.Mono;
 import java.net.URI;
+import java.time.Duration;
 import java.util.Optional;
@@ -17,28 +18,44 @@ import static org.mockito.ArgumentMatchers.any;
 public class UrlShortenerServiceTest {
     private Hasher hasher;
     private UrlRepository urlRepository;
 
     @Before
     public void setup() {
         hasher = Mockito.mock(Hasher.class);
         urlRepository = Mockito.mock(UrlRepository.class);
 
         Mockito.when(hasher.hash(any())).thenReturn("hash");
         Mockito.when(urlRepository.store(any()))
                .thenAnswer(invocation -> Mono.just(invocation.getArgument(0))); //echo back same response
     }
 
     @Test
     public void shouldCreateValidShortenedUrl() {
         final URI uri = URI.create("www.google.com");
 
         UrlShortenerService urlShortenerService = new UrlShortenerService(hasher, urlRepository);
         ShortenedUrl shortenedUrl = urlShortenerService.hashUrl(new UrlRequestBody(uri, Optional.empty()))
                                                        .block();
 
         assertThat(shortenedUrl, notNullValue());
         assertThat(shortenedUrl.getHashedUrl(), equalTo("hash"));
         assertThat(shortenedUrl.getOriginalUrl(), equalTo(uri));
         assertThat(shortenedUrl.getTtl(), equalTo(UrlShortenerService.DEFAULT_TTL));
     }
+
+
+    @Test
+    public void shouldCreateValidShortenedUrlWithProvidedTtl() {
+        final URI uri = URI.create("www.google.com");
+        final Long ttl = Duration.ofHours(5).toMillis();
+
+        UrlShortenerService urlShortenerService = new UrlShortenerService(hasher, urlRepository);
+        ShortenedUrl shortenedUrl = urlShortenerService.hashUrl(new UrlRequestBody(uri, Optional.of(ttl)))
+                                                       .block();
+
+        assertThat(shortenedUrl, notNullValue());
+        assertThat(shortenedUrl.getHashedUrl(), equalTo("hash"));
+        assertThat(shortenedUrl.getOriginalUrl(), equalTo(uri));
+        assertThat(shortenedUrl.getTtl(), equalTo(Duration.ofMillis(ttl)));
+    }
 }
\ No newline at end of file

commit 45ff3c669e5997618f91baad524811de4f2075e8
Author: Omar Olivares <oaro@kth.se>
Date:   Sun May 26 15:46:12 2019 +0200

    Add missing tests

diff --git a/src/main/java/io/github/miniurl/urlshortener/UrlShortenerService.java b/src/main/java/io/github/miniurl/urlshortener/UrlShortenerService.java
index 7d6bd03..e16e040 100644
--- a/src/main/java/io/github/miniurl/urlshortener/UrlShortenerService.java
+++ b/src/main/java/io/github/miniurl/urlshortener/UrlShortenerService.java
@@ -14,25 +14,35 @@ import static org.valid4j.Assertive.require;
 @Service
 public class UrlShortenerService {
-    private final static Duration DEFAULT_EXPIRATION = Duration.ofDays(365 * 2); //approx...
+    //ttl is enforced, so we'll need to define a default TTL
+    public final static Duration DEFAULT_TTL = Duration.ofDays(365 * 2); //approx...
     private final Hasher hasher;
     private final UrlRepository urlRepository;
 
     @Autowired
     public UrlShortenerService(Hasher hasher, UrlRepository urlRepository) {
         this.hasher = require(hasher, notNullValue());
         this.urlRepository = require(urlRepository, notNullValue());
     }
 
+    /**
+     * Hashes & stores a URL wrapped in a UrlRequestBody. Will normalize the URL
+     * to reduce "duplicate" urls that may differ but point to same location.
+     * TTL is optional but will use a default TTL of ~2 years if not provided.
+     *
+     * @param urlRequestBody Request body of a url to be hashed
+     * @return A domain object representing the hashed url
+     */
     public Mono<ShortenedUrl> hashUrl(UrlRequestBody urlRequestBody) {
         URI normalizedUrl = urlRequestBody.getUrl()
                                           .normalize();
         String hashedUrl = hasher.hash(normalizedUrl);
+
         Duration ttl = urlRequestBody.getTtl()
                                      .map(Duration::ofMillis)
-                                     .orElse(DEFAULT_EXPIRATION);
+                                     .orElse(DEFAULT_TTL);
 
         return urlRepository.store(new ShortenedUrl(normalizedUrl, hashedUrl, ttl))
                             .log()
                             .onErrorMap(throwable -> new UrlShortenerException("Failed to store hashed URL", throwable));
     }
 }
diff --git a/src/test/java/io/github/miniurl/urlshortener/UrlShortenerServiceTest.java b/src/test/java/io/github/miniurl/urlshortener/UrlShortenerServiceTest.java
new file mode 100644
index 0000000..1aab8ea
--- /dev/null
+++ b/src/test/java/io/github/miniurl/urlshortener/UrlShortenerServiceTest.java
@@ -0,0 +1,44 @@
+package io.github.miniurl.urlshortener;
+
+import io.github.miniurl.api.UrlRequestBody;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import reactor.core.publisher.Mono;
+
+import java.net.URI;
+import java.util.Optional;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.mockito.ArgumentMatchers.any;
+
+public class UrlShortenerServiceTest {
+    private Hasher hasher;
+    private UrlRepository urlRepository;
+
+    @Before
+    public void setup() {
+        hasher = Mockito.mock(Hasher.class);
+        urlRepository = Mockito.mock(UrlRepository.class);
+
+        Mockito.when(hasher.hash(any())).thenReturn("hash");
+        Mockito.when(urlRepository.store(any()))
+               .thenAnswer(invocation -> Mono.just(invocation.getArgument(0))); //echo back same response
+    }
+
+    @Test
+    public void shouldCreateValidShortenedUrl() {
+        final URI uri = URI.create("www.google.com");
+
+        UrlShortenerService urlShortenerService = new UrlShortenerService(hasher, urlRepository);
+        ShortenedUrl shortenedUrl = urlShortenerService.hashUrl(new UrlRequestBody(uri, Optional.empty()))
+                                                       .block();
+
+        assertThat(shortenedUrl, notNullValue());
+        assertThat(shortenedUrl.getHashedUrl(), equalTo("hash"));
+        assertThat(shortenedUrl.getOriginalUrl(), equalTo(uri));
+        assertThat(shortenedUrl.getTtl(), equalTo(UrlShortenerService.DEFAULT_TTL));
+    }
+}
\ No newline at end of file

commit d4aeb19faa6e498fe6234207d33359560e4d0787
Author: Omar Olivares <oaro@kth.se>
Date:   Sun May 26 15:16:28 2019 +0200

    Refactor pipeline when storing in redis. Proper usage of TestContainers in IT

diff --git a/src/main/java/io/github/miniurl/urlshortener/ShortenedUrl.java b/src/main/java/io/github/miniurl/urlshortener/ShortenedUrl.java
index c923893..6712cf4 100644
--- a/src/main/java/io/github/miniurl/urlshortener/ShortenedUrl.java
+++ b/src/main/java/io/github/miniurl/urlshortener/ShortenedUrl.java
@@ -3,4 +3,2 @@ package io.github.miniurl.urlshortener;
 import lombok.Data;
-import lombok.Getter;
-import lombok.ToString;
 
diff --git a/src/main/java/io/github/miniurl/urlshortener/UrlRepository.java b/src/main/java/io/github/miniurl/urlshortener/UrlRepository.java
index 487f328..3f0df4b 100644
--- a/src/main/java/io/github/miniurl/urlshortener/UrlRepository.java
+++ b/src/main/java/io/github/miniurl/urlshortener/UrlRepository.java
@@ -12,14 +12,15 @@ import static org.valid4j.Assertive.require;
 @Repository
 public class UrlRepository {
     private final ReactiveRedisTemplate<String, String> redisTemplate;
 
     @Autowired
     public UrlRepository(ReactiveRedisTemplate<String, String> redisTemplate) {
         this.redisTemplate = require(redisTemplate, notNullValue());
     }
 
-    public Mono<Boolean> store(ShortenedUrl shortenedUrl) {
+    public Mono<ShortenedUrl> store(ShortenedUrl shortenedUrl) {
         return redisTemplate.opsForValue()
-                            .set(shortenedUrl.getHashedUrl(), shortenedUrl.getOriginalUrl().toString(), shortenedUrl.getTtl());
+                            .set(shortenedUrl.getHashedUrl(), shortenedUrl.getOriginalUrl().toString(), shortenedUrl.getTtl())
+                            .then(Mono.just(shortenedUrl));
     }
 }
diff --git a/src/main/java/io/github/miniurl/urlshortener/UrlShortenerService.java b/src/main/java/io/github/miniurl/urlshortener/UrlShortenerService.java
index cade3bb..7d6bd03 100644
--- a/src/main/java/io/github/miniurl/urlshortener/UrlShortenerService.java
+++ b/src/main/java/io/github/miniurl/urlshortener/UrlShortenerService.java
@@ -14,26 +14,25 @@ import static org.valid4j.Assertive.require;
 @Service
 public class UrlShortenerService {
     private final static Duration DEFAULT_EXPIRATION = Duration.ofDays(365 * 2); //approx...
     private final Hasher hasher;
     private final UrlRepository urlRepository;
 
     @Autowired
     public UrlShortenerService(Hasher hasher, UrlRepository urlRepository) {
         this.hasher = require(hasher, notNullValue());
         this.urlRepository = require(urlRepository, notNullValue());
     }
 
     public Mono<ShortenedUrl> hashUrl(UrlRequestBody urlRequestBody) {
         URI normalizedUrl = urlRequestBody.getUrl()
                                           .normalize();
         String hashedUrl = hasher.hash(normalizedUrl);
         Duration ttl = urlRequestBody.getTtl()
                                      .map(Duration::ofMillis)
                                      .orElse(DEFAULT_EXPIRATION);
 
-        return Mono.just(new ShortenedUrl(normalizedUrl, hashedUrl, ttl))
-                   .log()
-                   .doOnNext(urlRepository::store)
-                   .onErrorMap(throwable -> new UrlShortenerException("Failed to store hashed URL", throwable));
+        return urlRepository.store(new ShortenedUrl(normalizedUrl, hashedUrl, ttl))
+                            .log()
+                            .onErrorMap(throwable -> new UrlShortenerException("Failed to store hashed URL", throwable));
     }
 }
diff --git a/src/test/java/io/github/miniurl/it/BaseIT.java b/src/test/java/io/github/miniurl/it/BaseIT.java
new file mode 100644
index 0000000..ff716cd
--- /dev/null
+++ b/src/test/java/io/github/miniurl/it/BaseIT.java
@@ -0,0 +1,33 @@
+package io.github.miniurl.it;
+
+import io.github.miniurl.Environment;
+import io.github.miniurl.MiniUrlApplication;
+import org.junit.ClassRule;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.util.TestPropertyValues;
+import org.springframework.context.ApplicationContextInitializer;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.testcontainers.containers.GenericContainer;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = MiniUrlApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@ContextConfiguration(initializers = BaseIT.Initializer.class)
+public abstract class BaseIT {
+    @ClassRule
+    public static GenericContainer redis = new GenericContainer("redis:5.0.5").withExposedPorts(Environment.REDIS_PORT);
+
+    public static class Initializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {
+        @Override
+        public void initialize(ConfigurableApplicationContext configurableApplicationContext) {
+            TestPropertyValues values = TestPropertyValues.of(
+                    "spring.redis.host=" + redis.getContainerIpAddress(),
+                    "spring.redis.port=" + redis.getMappedPort(6379)
+            );
+            values.applyTo(configurableApplicationContext);
+        }
+    }
+
+}
diff --git a/src/test/java/io/github/miniurl/it/MiniUrlCreateIT.java b/src/test/java/io/github/miniurl/it/MiniUrlCreateIT.java
index 1cb5653..3a49fd0 100644
--- a/src/test/java/io/github/miniurl/it/MiniUrlCreateIT.java
+++ b/src/test/java/io/github/miniurl/it/MiniUrlCreateIT.java
@@ -2,19 +2,11 @@ package io.github.miniurl.it;
 
-import io.github.miniurl.Environment;
 import io.github.miniurl.api.UrlRequestBody;
 import io.github.miniurl.api.UrlResponseBody;
-import org.junit.Before;
-import org.junit.ClassRule;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.ApplicationContext;
 import org.springframework.data.redis.core.ReactiveRedisTemplate;
-import org.springframework.test.context.junit4.SpringRunner;
-import org.springframework.test.web.reactive.server.FluxExchangeResult;
 import org.springframework.test.web.reactive.server.WebTestClient;
 import org.springframework.web.reactive.function.BodyInserters;
-import org.testcontainers.containers.GenericContainer;
+import reactor.core.publisher.Mono;
 
@@ -23,33 +15,39 @@ import java.util.Optional;
 
+import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.IsNull.notNullValue;
 
-@RunWith(SpringRunner.class)
-@SpringBootTest
 @AutoConfigureWebTestClient
-public class MiniUrlCreateIT {
-    @ClassRule
-    public static GenericContainer redis = new GenericContainer("redis:5.0.5").withExposedPorts(Environment.REDIS_PORT);
+public class MiniUrlCreateIT extends BaseIT {
 
     @Autowired
     private WebTestClient webClient;
 
+    @Autowired
+    private ReactiveRedisTemplate<String, String> redisTemplate;
+
     @Test
     public void shouldCreateHashedUrl() {
-        final UrlRequestBody request = new UrlRequestBody(URI.create("www.google.com"), Optional.of(15_000L));
+        final URI uri = URI.create("www.google.com");
+        final UrlRequestBody request = new UrlRequestBody(uri, Optional.of(15_000L));
 
         UrlResponseBody result = webClient.post()
                                           .uri("/")
                                           .body(BodyInserters.fromObject(request))
                                           .exchange()
                                           .expectStatus().isOk()
                                           .returnResult(UrlResponseBody.class)
                                           .getResponseBody()
                                           .blockFirst();
-
+        //Verify response
         assertThat(result, notNullValue());
         assertThat(result.getUrl(), notNullValue());
 
-        //todo: assert redis state
+        //Verify state in redis
+        URI actualOriginalUri = redisTemplate.opsForValue()
+                                             .get(result.getUrl().getPath())
+                                             .map(URI::create)
+                                             .block();
+        assertThat(actualOriginalUri, equalTo(uri));
     }
 }
diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml
deleted file mode 100644
index 22a2799..0000000
--- a/src/test/resources/application.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-spring:
-  redis:
-    host: localhost
-    port: 6379
-
-server:
-  port: 8080
\ No newline at end of file

commit bc1252665ef9055bfa0b0134040178598674d185
Author: Omar Olivares <oaro@kth.se>
Date:   Sun May 26 14:22:00 2019 +0200

    Add initial IT & minor cleanup based on initial testing

diff --git a/pom.xml b/pom.xml
index 34eb4ab..f24ae8a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,77 +1,84 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
         <version>2.1.5.RELEASE</version>
         <relativePath/> <!-- lookup parent from repository -->
     </parent>
     <groupId>io.github</groupId>
     <artifactId>miniurl</artifactId>
     <version>0.0.1-SNAPSHOT</version>
     <name>miniurl</name>
     <description>Demo project for Spring Boot</description>
 
     <properties>
         <java.version>11</java.version>
     </properties>
 
     <dependencies>
 
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-data-redis-reactive</artifactId>
         </dependency>
 
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-webflux</artifactId>
         </dependency>
 
         <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
         <dependency>
             <groupId>org.projectlombok</groupId>
             <artifactId>lombok</artifactId>
             <version>1.18.0</version>
             <scope>provided</scope>
         </dependency>
 
         <!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
         <dependency>
             <groupId>com.google.guava</groupId>
             <artifactId>guava</artifactId>
             <version>27.1-jre</version>
         </dependency>
 
         <dependency>
             <groupId>org.valid4j</groupId>
             <artifactId>valid4j</artifactId>
             <version>0.5.0</version>
         </dependency>
 
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-test</artifactId>
             <scope>test</scope>
         </dependency>
 
         <dependency>
             <groupId>io.projectreactor</groupId>
             <artifactId>reactor-test</artifactId>
             <scope>test</scope>
         </dependency>
 
+        <dependency>
+            <groupId>org.testcontainers</groupId>
+            <artifactId>testcontainers</artifactId>
+            <version>1.11.2</version>
+            <scope>test</scope>
+        </dependency>
+
     </dependencies>
 
     <build>
         <plugins>
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
             </plugin>
         </plugins>
     </build>
 
 </project>
diff --git a/src/main/java/io/github/miniurl/MiniurlApplication.java b/src/main/java/io/github/miniurl/MiniUrlApplication.java
similarity index 89%
rename from src/main/java/io/github/miniurl/MiniurlApplication.java
rename to src/main/java/io/github/miniurl/MiniUrlApplication.java
index 3294db3..7f47d87 100644
--- a/src/main/java/io/github/miniurl/MiniurlApplication.java
+++ b/src/main/java/io/github/miniurl/MiniUrlApplication.java
@@ -11,15 +11,15 @@ import org.springframework.data.redis.serializer.RedisSerializationContext;
 @SpringBootApplication
 @Configuration
-public class MiniurlApplication {
+public class MiniUrlApplication {
 
     public static void main(String[] args) {
-        SpringApplication.run(MiniurlApplication.class, args);
+        SpringApplication.run(MiniUrlApplication.class, args);
     }
 
     @Bean
     public ReactiveRedisTemplate<String, String> reactiveRedisTemplateString
             (ReactiveRedisConnectionFactory connectionFactory) {
         return new ReactiveRedisTemplate<>(connectionFactory, RedisSerializationContext.string());
     }
 
 }
diff --git a/src/main/java/io/github/miniurl/api/UrlRequestBody.java b/src/main/java/io/github/miniurl/api/UrlRequestBody.java
index 8213f18..cdaefd5 100644
--- a/src/main/java/io/github/miniurl/api/UrlRequestBody.java
+++ b/src/main/java/io/github/miniurl/api/UrlRequestBody.java
@@ -2,2 +2,3 @@ package io.github.miniurl.api;
 
+import lombok.AllArgsConstructor;
 import lombok.Data;
@@ -11,3 +12,4 @@ import java.util.Optional;
 @Data
 @NoArgsConstructor
+@AllArgsConstructor
 public class UrlRequestBody {
diff --git a/src/main/java/io/github/miniurl/api/UrlResponseBody.java b/src/main/java/io/github/miniurl/api/UrlResponseBody.java
index d768149..68c6dd8 100644
--- a/src/main/java/io/github/miniurl/api/UrlResponseBody.java
+++ b/src/main/java/io/github/miniurl/api/UrlResponseBody.java
@@ -4,2 +4,3 @@ import lombok.AllArgsConstructor;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 
@@ -8,5 +9,6 @@ import java.net.URI;
 @Data
 @AllArgsConstructor
+@NoArgsConstructor
 public class UrlResponseBody {
-    private final URI url;
+    private URI url;
 }
diff --git a/src/main/java/io/github/miniurl/controllers/UrlController.java b/src/main/java/io/github/miniurl/controllers/UrlController.java
index 1beb1dc..31bc3ac 100644
--- a/src/main/java/io/github/miniurl/controllers/UrlController.java
+++ b/src/main/java/io/github/miniurl/controllers/UrlController.java
@@ -5,2 +5,3 @@ import io.github.miniurl.api.UrlResponseBody;
 import io.github.miniurl.urlshortener.UrlShortenerService;
+import org.springframework.http.MediaType;
 import org.springframework.http.server.reactive.ServerHttpRequest;
@@ -19,28 +20,28 @@ import static org.valid4j.Assertive.require;
 @RestController
 public class UrlController {
     private final UrlShortenerService urlShortener;
 
     public UrlController(UrlShortenerService urlShortener) {
         this.urlShortener = require(urlShortener, notNullValue());
     }
 
-    @PostMapping
+    @PostMapping(produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
     public Mono<UrlResponseBody> hashUrl(@RequestBody @Valid UrlRequestBody request,
                                          ServerHttpRequest serverRequest) {
         return urlShortener.hashUrl(request)
                            .map(shortenedUrl -> generateResponseUrl(shortenedUrl.getHashedUrl(), serverRequest))
                            .map(UrlResponseBody::new);
     }
 
     //Construct baseUri from request-uri. Spring should in most cases
     //be able to infer from the http request the proper request URI
     private URI generateResponseUrl(String pathValue, ServerHttpRequest serverRequest) {
         URI requestUri = serverRequest.getURI();
 
         return UriComponentsBuilder.fromUri(requestUri)
                                    .replacePath(pathValue)
                                    .replaceQuery(null)
                                    .build()
                                    .toUri();
     }
 }
diff --git a/src/main/java/io/github/miniurl/urlshortener/ShortenedUrl.java b/src/main/java/io/github/miniurl/urlshortener/ShortenedUrl.java
index 0e4b21c..c923893 100644
--- a/src/main/java/io/github/miniurl/urlshortener/ShortenedUrl.java
+++ b/src/main/java/io/github/miniurl/urlshortener/ShortenedUrl.java
@@ -2,3 +2,5 @@ package io.github.miniurl.urlshortener;
 
+import lombok.Data;
 import lombok.Getter;
+import lombok.ToString;
 
@@ -11,4 +13,4 @@ import static org.valid4j.Assertive.require;
 import static org.valid4j.matchers.ArgumentMatchers.notEmptyString;
 
-@Getter
+@Data
 public class ShortenedUrl {
diff --git a/src/test/java/io/github/miniurl/Environment.java b/src/test/java/io/github/miniurl/Environment.java
new file mode 100644
index 0000000..c37d678
--- /dev/null
+++ b/src/test/java/io/github/miniurl/Environment.java
@@ -0,0 +1,6 @@
+package io.github.miniurl;
+
+public interface Environment {
+
+    int REDIS_PORT = 6379;
+}
diff --git a/src/test/java/io/github/miniurl/MiniurlApplicationTests.java b/src/test/java/io/github/miniurl/MiniUrlApplicationTests.java
similarity index 88%
rename from src/test/java/io/github/miniurl/MiniurlApplicationTests.java
rename to src/test/java/io/github/miniurl/MiniUrlApplicationTests.java
index d3fc39e..fcf6414 100644
--- a/src/test/java/io/github/miniurl/MiniurlApplicationTests.java
+++ b/src/test/java/io/github/miniurl/MiniUrlApplicationTests.java
@@ -8,9 +8,9 @@ import org.springframework.test.context.junit4.SpringRunner;
 @RunWith(SpringRunner.class)
 @SpringBootTest
-public class MiniurlApplicationTests {
+public class MiniUrlApplicationTests {
 
 	@Test
 	public void contextLoads() {
 	}
 
 }
diff --git a/src/test/java/io/github/miniurl/it/MiniUrlCreateIT.java b/src/test/java/io/github/miniurl/it/MiniUrlCreateIT.java
new file mode 100644
index 0000000..1cb5653
--- /dev/null
+++ b/src/test/java/io/github/miniurl/it/MiniUrlCreateIT.java
@@ -0,0 +1,55 @@
+package io.github.miniurl.it;
+
+import io.github.miniurl.Environment;
+import io.github.miniurl.api.UrlRequestBody;
+import io.github.miniurl.api.UrlResponseBody;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.ApplicationContext;
+import org.springframework.data.redis.core.ReactiveRedisTemplate;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.web.reactive.server.FluxExchangeResult;
+import org.springframework.test.web.reactive.server.WebTestClient;
+import org.springframework.web.reactive.function.BodyInserters;
+import org.testcontainers.containers.GenericContainer;
+
+import java.net.URI;
+import java.util.Optional;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.IsNull.notNullValue;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+@AutoConfigureWebTestClient
+public class MiniUrlCreateIT {
+    @ClassRule
+    public static GenericContainer redis = new GenericContainer("redis:5.0.5").withExposedPorts(Environment.REDIS_PORT);
+
+    @Autowired
+    private WebTestClient webClient;
+
+    @Test
+    public void shouldCreateHashedUrl() {
+        final UrlRequestBody request = new UrlRequestBody(URI.create("www.google.com"), Optional.of(15_000L));
+
+        UrlResponseBody result = webClient.post()
+                                          .uri("/")
+                                          .body(BodyInserters.fromObject(request))
+                                          .exchange()
+                                          .expectStatus().isOk()
+                                          .returnResult(UrlResponseBody.class)
+                                          .getResponseBody()
+                                          .blockFirst();
+
+        assertThat(result, notNullValue());
+        assertThat(result.getUrl(), notNullValue());
+
+        //todo: assert redis state
+    }
+}
diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml
new file mode 100644
index 0000000..22a2799
--- /dev/null
+++ b/src/test/resources/application.yml
@@ -0,0 +1,7 @@
+spring:
+  redis:
+    host: localhost
+    port: 6379
+
+server:
+  port: 8080
\ No newline at end of file

commit fdc0e7b6121dc41984dc67083431a7c35c88f054
Author: Omar Olivares <oaro@kth.se>
Date:   Sun May 26 13:31:06 2019 +0200

    Initial implementatio of creating a hashed url

diff --git a/pom.xml b/pom.xml
index 1a9dc49..34eb4ab 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,64 +1,77 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-	<modelVersion>4.0.0</modelVersion>
-	<parent>
-		<groupId>org.springframework.boot</groupId>
-		<artifactId>spring-boot-starter-parent</artifactId>
-		<version>2.1.5.RELEASE</version>
-		<relativePath/> <!-- lookup parent from repository -->
-	</parent>
-	<groupId>io.github</groupId>
-	<artifactId>miniurl</artifactId>
-	<version>0.0.1-SNAPSHOT</version>
-	<name>miniurl</name>
-	<description>Demo project for Spring Boot</description>
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.1.5.RELEASE</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+    <groupId>io.github</groupId>
+    <artifactId>miniurl</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <name>miniurl</name>
+    <description>Demo project for Spring Boot</description>
 
-	<properties>
-		<java.version>11</java.version>
-	</properties>
+    <properties>
+        <java.version>11</java.version>
+    </properties>
 
-	<dependencies>
+    <dependencies>
 
-		<dependency>
-			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-data-redis-reactive</artifactId>
-		</dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-redis-reactive</artifactId>
+        </dependency>
 
-		<dependency>
-			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-webflux</artifactId>
-		</dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-webflux</artifactId>
+        </dependency>
 
-		<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
-		<dependency>
-			<groupId>org.projectlombok</groupId>
-			<artifactId>lombok</artifactId>
-			<version>1.18.0</version>
-			<scope>provided</scope>
-		</dependency>
+        <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>1.18.0</version>
+            <scope>provided</scope>
+        </dependency>
 
-		<dependency>
-			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-test</artifactId>
-			<scope>test</scope>
-		</dependency>
+        <!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>27.1-jre</version>
+        </dependency>
 
-		<dependency>
-			<groupId>io.projectreactor</groupId>
-			<artifactId>reactor-test</artifactId>
-			<scope>test</scope>
-		</dependency>
+        <dependency>
+            <groupId>org.valid4j</groupId>
+            <artifactId>valid4j</artifactId>
+            <version>0.5.0</version>
+        </dependency>
 
-	</dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
 
-	<build>
-		<plugins>
-			<plugin>
-				<groupId>org.springframework.boot</groupId>
-				<artifactId>spring-boot-maven-plugin</artifactId>
-			</plugin>
-		</plugins>
-	</build>
+        <dependency>
+            <groupId>io.projectreactor</groupId>
+            <artifactId>reactor-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
 
 </project>
diff --git a/src/main/java/io/github/miniurl/MiniurlApplication.java b/src/main/java/io/github/miniurl/MiniurlApplication.java
index ccfc3ad..3294db3 100644
--- a/src/main/java/io/github/miniurl/MiniurlApplication.java
+++ b/src/main/java/io/github/miniurl/MiniurlApplication.java
@@ -4,10 +4,22 @@ import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.ReactiveRedisConnectionFactory;
+import org.springframework.data.redis.core.ReactiveRedisTemplate;
+import org.springframework.data.redis.serializer.RedisSerializationContext;
 
 @SpringBootApplication
+@Configuration
 public class MiniurlApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(MiniurlApplication.class, args);
     }
 
+    @Bean
+    public ReactiveRedisTemplate<String, String> reactiveRedisTemplateString
+            (ReactiveRedisConnectionFactory connectionFactory) {
+        return new ReactiveRedisTemplate<>(connectionFactory, RedisSerializationContext.string());
+    }
+
 }
diff --git a/src/main/java/io/github/miniurl/controllers/UrlController.java b/src/main/java/io/github/miniurl/controllers/UrlController.java
index 2d683ca..1beb1dc 100644
--- a/src/main/java/io/github/miniurl/controllers/UrlController.java
+++ b/src/main/java/io/github/miniurl/controllers/UrlController.java
@@ -4,2 +4,4 @@ import io.github.miniurl.api.UrlRequestBody;
 import io.github.miniurl.api.UrlResponseBody;
+import io.github.miniurl.urlshortener.UrlShortenerService;
+import org.springframework.http.server.reactive.ServerHttpRequest;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -7,2 +9,3 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.util.UriComponentsBuilder;
 import reactor.core.publisher.Mono;
@@ -11,10 +14,33 @@ import javax.validation.Valid;
 import java.net.URI;
 
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.valid4j.Assertive.require;
+
 @RestController
 public class UrlController {
+    private final UrlShortenerService urlShortener;
+
+    public UrlController(UrlShortenerService urlShortener) {
+        this.urlShortener = require(urlShortener, notNullValue());
+    }
 
     @PostMapping
-    public Mono<UrlResponseBody> hashUrl(@RequestBody @Valid UrlRequestBody request) {
-        return Mono.just(new UrlResponseBody(URI.create("localhost.com")));
+    public Mono<UrlResponseBody> hashUrl(@RequestBody @Valid UrlRequestBody request,
+                                         ServerHttpRequest serverRequest) {
+        return urlShortener.hashUrl(request)
+                           .map(shortenedUrl -> generateResponseUrl(shortenedUrl.getHashedUrl(), serverRequest))
+                           .map(UrlResponseBody::new);
+    }
+
+    //Construct baseUri from request-uri. Spring should in most cases
+    //be able to infer from the http request the proper request URI
+    private URI generateResponseUrl(String pathValue, ServerHttpRequest serverRequest) {
+        URI requestUri = serverRequest.getURI();
+
+        return UriComponentsBuilder.fromUri(requestUri)
+                                   .replacePath(pathValue)
+                                   .replaceQuery(null)
+                                   .build()
+                                   .toUri();
     }
 }
diff --git a/src/main/java/io/github/miniurl/urlshortener/Hasher.java b/src/main/java/io/github/miniurl/urlshortener/Hasher.java
new file mode 100644
index 0000000..3d710e6
--- /dev/null
+++ b/src/main/java/io/github/miniurl/urlshortener/Hasher.java
@@ -0,0 +1,31 @@
+package io.github.miniurl.urlshortener;
+
+import com.google.common.hash.Hashing;
+import org.springframework.stereotype.Component;
+
+import java.net.URI;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.valid4j.Assertive.require;
+
+public interface Hasher {
+
+    String hash(URI url);
+
+    @SuppressWarnings("UnstableApiUsage")
+    @Component
+    class Murmur32Hasher implements Hasher {
+        private final static Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
+
+        @Override
+        public String hash(URI url) {
+            require(url, notNullValue());
+
+            return Hashing.murmur3_32()
+                          .hashString(url.toString(), DEFAULT_CHARSET)
+                          .toString();
+        }
+    }
+}
diff --git a/src/main/java/io/github/miniurl/urlshortener/ShortenedUrl.java b/src/main/java/io/github/miniurl/urlshortener/ShortenedUrl.java
new file mode 100644
index 0000000..0e4b21c
--- /dev/null
+++ b/src/main/java/io/github/miniurl/urlshortener/ShortenedUrl.java
@@ -0,0 +1,28 @@
+package io.github.miniurl.urlshortener;
+
+import lombok.Getter;
+
+import java.net.URI;
+import java.time.Duration;
+
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.valid4j.Assertive.ensure;
+import static org.valid4j.Assertive.require;
+import static org.valid4j.matchers.ArgumentMatchers.notEmptyString;
+
+@Getter
+public class ShortenedUrl {
+    private final URI originalUrl;
+    private final String hashedUrl;
+    private final Duration ttl;
+
+    //Proper domain validation when instantiating
+    public ShortenedUrl(URI originalUrl,
+                        String hashedUrl,
+                        Duration ttl) {
+        this.originalUrl = require(originalUrl, notNullValue());
+        this.hashedUrl = require(hashedUrl, notEmptyString());
+        this.ttl = require(ttl, notNullValue());
+        ensure(!(ttl.isZero() && ttl.isNegative())); //Ensure ttl is positive
+    }
+}
diff --git a/src/main/java/io/github/miniurl/urlshortener/UrlRepository.java b/src/main/java/io/github/miniurl/urlshortener/UrlRepository.java
new file mode 100644
index 0000000..487f328
--- /dev/null
+++ b/src/main/java/io/github/miniurl/urlshortener/UrlRepository.java
@@ -0,0 +1,25 @@
+package io.github.miniurl.urlshortener;
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.ReactiveRedisTemplate;
+import org.springframework.stereotype.Repository;
+import reactor.core.publisher.Mono;
+
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.valid4j.Assertive.require;
+
+@Repository
+public class UrlRepository {
+    private final ReactiveRedisTemplate<String, String> redisTemplate;
+
+    @Autowired
+    public UrlRepository(ReactiveRedisTemplate<String, String> redisTemplate) {
+        this.redisTemplate = require(redisTemplate, notNullValue());
+    }
+
+    public Mono<Boolean> store(ShortenedUrl shortenedUrl) {
+        return redisTemplate.opsForValue()
+                            .set(shortenedUrl.getHashedUrl(), shortenedUrl.getOriginalUrl().toString(), shortenedUrl.getTtl());
+    }
+}
diff --git a/src/main/java/io/github/miniurl/urlshortener/UrlShortenerException.java b/src/main/java/io/github/miniurl/urlshortener/UrlShortenerException.java
new file mode 100644
index 0000000..e6fceb0
--- /dev/null
+++ b/src/main/java/io/github/miniurl/urlshortener/UrlShortenerException.java
@@ -0,0 +1,7 @@
+package io.github.miniurl.urlshortener;
+
+public class UrlShortenerException extends RuntimeException {
+    public UrlShortenerException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}
diff --git a/src/main/java/io/github/miniurl/urlshortener/UrlShortenerService.java b/src/main/java/io/github/miniurl/urlshortener/UrlShortenerService.java
new file mode 100644
index 0000000..cade3bb
--- /dev/null
+++ b/src/main/java/io/github/miniurl/urlshortener/UrlShortenerService.java
@@ -0,0 +1,39 @@
+package io.github.miniurl.urlshortener;
+
+import io.github.miniurl.api.UrlRequestBody;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import reactor.core.publisher.Mono;
+
+import java.net.URI;
+import java.time.Duration;
+
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.valid4j.Assertive.require;
+
+@Service
+public class UrlShortenerService {
+    private final static Duration DEFAULT_EXPIRATION = Duration.ofDays(365 * 2); //approx...
+    private final Hasher hasher;
+    private final UrlRepository urlRepository;
+
+    @Autowired
+    public UrlShortenerService(Hasher hasher, UrlRepository urlRepository) {
+        this.hasher = require(hasher, notNullValue());
+        this.urlRepository = require(urlRepository, notNullValue());
+    }
+
+    public Mono<ShortenedUrl> hashUrl(UrlRequestBody urlRequestBody) {
+        URI normalizedUrl = urlRequestBody.getUrl()
+                                          .normalize();
+        String hashedUrl = hasher.hash(normalizedUrl);
+        Duration ttl = urlRequestBody.getTtl()
+                                     .map(Duration::ofMillis)
+                                     .orElse(DEFAULT_EXPIRATION);
+
+        return Mono.just(new ShortenedUrl(normalizedUrl, hashedUrl, ttl))
+                   .log()
+                   .doOnNext(urlRepository::store)
+                   .onErrorMap(throwable -> new UrlShortenerException("Failed to store hashed URL", throwable));
+    }
+}

commit dd8458b2b6ef1b86d17f16b242eb5cea62408ffa
Author: gunbuster135 <oaro@kth.se>
Date:   Fri May 24 22:35:59 2019 +0200

    Add README

diff --git a/README.md b/README.md
new file mode 100644
index 0000000..85daf0e
--- /dev/null
+++ b/README.md
@@ -0,0 +1,2 @@
+# MiniUrl
+A reactive implementation of a URL minifier

commit 639ecf7c9d1c8aa393ad1abfcdf64434219d877b
Author: Omar Olivares <oaro@kth.se>
Date:   Fri May 24 22:34:21 2019 +0200

    Initial commit with dummy controller

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..153c933
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,29 @@
+HELP.md
+/target/
+!.mvn/wrapper/maven-wrapper.jar
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+/build/
+
+### VS Code ###
+.vscode/
diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java
new file mode 100644
index 0000000..72308aa
--- /dev/null
+++ b/.mvn/wrapper/MavenWrapperDownloader.java
@@ -0,0 +1,114 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  https://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.nio.channels.Channels;
+import java.nio.channels.ReadableByteChannel;
+import java.util.Properties;
+
+public class MavenWrapperDownloader {
+
+    /**
+     * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
+     */
+    private static final String DEFAULT_DOWNLOAD_URL =
+            "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar";
+
+    /**
+     * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
+     * use instead of the default one.
+     */
+    private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
+            ".mvn/wrapper/maven-wrapper.properties";
+
+    /**
+     * Path where the maven-wrapper.jar will be saved to.
+     */
+    private static final String MAVEN_WRAPPER_JAR_PATH =
+            ".mvn/wrapper/maven-wrapper.jar";
+
+    /**
+     * Name of the property which should be used to override the default download url for the wrapper.
+     */
+    private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
+
+    public static void main(String args[]) {
+        System.out.println("- Downloader started");
+        File baseDirectory = new File(args[0]);
+        System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
+
+        // If the maven-wrapper.properties exists, read it and check if it contains a custom
+        // wrapperUrl parameter.
+        File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
+        String url = DEFAULT_DOWNLOAD_URL;
+        if(mavenWrapperPropertyFile.exists()) {
+            FileInputStream mavenWrapperPropertyFileInputStream = null;
+            try {
+                mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
+                Properties mavenWrapperProperties = new Properties();
+                mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
+                url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
+            } catch (IOException e) {
+                System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
+            } finally {
+                try {
+                    if(mavenWrapperPropertyFileInputStream != null) {
+                        mavenWrapperPropertyFileInputStream.close();
+                    }
+                } catch (IOException e) {
+                    // Ignore ...
+                }
+            }
+        }
+        System.out.println("- Downloading from: : " + url);
+
+        File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
+        if(!outputFile.getParentFile().exists()) {
+            if(!outputFile.getParentFile().mkdirs()) {
+                System.out.println(
+                        "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
+            }
+        }
+        System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
+        try {
+            downloadFileFromURL(url, outputFile);
+            System.out.println("Done");
+            System.exit(0);
+        } catch (Throwable e) {
+            System.out.println("- Error downloading");
+            e.printStackTrace();
+            System.exit(1);
+        }
+    }
+
+    private static void downloadFileFromURL(String urlString, File destination) throws Exception {
+        URL website = new URL(urlString);
+        ReadableByteChannel rbc;
+        rbc = Channels.newChannel(website.openStream());
+        FileOutputStream fos = new FileOutputStream(destination);
+        fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
+        fos.close();
+        rbc.close();
+    }
+
+}
diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar
new file mode 100644
index 0000000..01e6799
Binary files /dev/null and b/.mvn/wrapper/maven-wrapper.jar differ
diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties
new file mode 100644
index 0000000..cd0d451
--- /dev/null
+++ b/.mvn/wrapper/maven-wrapper.properties
@@ -0,0 +1 @@
+distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
diff --git a/mvnw b/mvnw
new file mode 100755
index 0000000..8b9da3b
--- /dev/null
+++ b/mvnw
@@ -0,0 +1,286 @@
+#!/bin/sh
+# ----------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#    https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ----------------------------------------------------------------------------
+
+# ----------------------------------------------------------------------------
+# Maven2 Start Up Batch script
+#
+# Required ENV vars:
+# ------------------
+#   JAVA_HOME - location of a JDK home dir
+#
+# Optional ENV vars
+# -----------------
+#   M2_HOME - location of maven2's installed home dir
+#   MAVEN_OPTS - parameters passed to the Java VM when running Maven
+#     e.g. to debug Maven itself, use
+#       set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+#   MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+# ----------------------------------------------------------------------------
+
+if [ -z "$MAVEN_SKIP_RC" ] ; then
+
+  if [ -f /etc/mavenrc ] ; then
+    . /etc/mavenrc
+  fi
+
+  if [ -f "$HOME/.mavenrc" ] ; then
+    . "$HOME/.mavenrc"
+  fi
+
+fi
+
+# OS specific support.  $var _must_ be set to either true or false.
+cygwin=false;
+darwin=false;
+mingw=false
+case "`uname`" in
+  CYGWIN*) cygwin=true ;;
+  MINGW*) mingw=true;;
+  Darwin*) darwin=true
+    # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
+    # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
+    if [ -z "$JAVA_HOME" ]; then
+      if [ -x "/usr/libexec/java_home" ]; then
+        export JAVA_HOME="`/usr/libexec/java_home`"
+      else
+        export JAVA_HOME="/Library/Java/Home"
+      fi
+    fi
+    ;;
+esac
+
+if [ -z "$JAVA_HOME" ] ; then
+  if [ -r /etc/gentoo-release ] ; then
+    JAVA_HOME=`java-config --jre-home`
+  fi
+fi
+
+if [ -z "$M2_HOME" ] ; then
+  ## resolve links - $0 may be a link to maven's home
+  PRG="$0"
+
+  # need this for relative symlinks
+  while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+      PRG="$link"
+    else
+      PRG="`dirname "$PRG"`/$link"
+    fi
+  done
+
+  saveddir=`pwd`
+
+  M2_HOME=`dirname "$PRG"`/..
+
+  # make it fully qualified
+  M2_HOME=`cd "$M2_HOME" && pwd`
+
+  cd "$saveddir"
+  # echo Using m2 at $M2_HOME
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+  [ -n "$M2_HOME" ] &&
+    M2_HOME=`cygpath --unix "$M2_HOME"`
+  [ -n "$JAVA_HOME" ] &&
+    JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+  [ -n "$CLASSPATH" ] &&
+    CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
+fi
+
+# For Mingw, ensure paths are in UNIX format before anything is touched
+if $mingw ; then
+  [ -n "$M2_HOME" ] &&
+    M2_HOME="`(cd "$M2_HOME"; pwd)`"
+  [ -n "$JAVA_HOME" ] &&
+    JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
+  # TODO classpath?
+fi
+
+if [ -z "$JAVA_HOME" ]; then
+  javaExecutable="`which javac`"
+  if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
+    # readlink(1) is not available as standard on Solaris 10.
+    readLink=`which readlink`
+    if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
+      if $darwin ; then
+        javaHome="`dirname \"$javaExecutable\"`"
+        javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
+      else
+        javaExecutable="`readlink -f \"$javaExecutable\"`"
+      fi
+      javaHome="`dirname \"$javaExecutable\"`"
+      javaHome=`expr "$javaHome" : '\(.*\)/bin'`
+      JAVA_HOME="$javaHome"
+      export JAVA_HOME
+    fi
+  fi
+fi
+
+if [ -z "$JAVACMD" ] ; then
+  if [ -n "$JAVA_HOME"  ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+      # IBM's JDK on AIX uses strange locations for the executables
+      JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+      JAVACMD="$JAVA_HOME/bin/java"
+    fi
+  else
+    JAVACMD="`which java`"
+  fi
+fi
+
+if [ ! -x "$JAVACMD" ] ; then
+  echo "Error: JAVA_HOME is not defined correctly." >&2
+  echo "  We cannot execute $JAVACMD" >&2
+  exit 1
+fi
+
+if [ -z "$JAVA_HOME" ] ; then
+  echo "Warning: JAVA_HOME environment variable is not set."
+fi
+
+CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
+
+# traverses directory structure from process work directory to filesystem root
+# first directory with .mvn subdirectory is considered project base directory
+find_maven_basedir() {
+
+  if [ -z "$1" ]
+  then
+    echo "Path not specified to find_maven_basedir"
+    return 1
+  fi
+
+  basedir="$1"
+  wdir="$1"
+  while [ "$wdir" != '/' ] ; do
+    if [ -d "$wdir"/.mvn ] ; then
+      basedir=$wdir
+      break
+    fi
+    # workaround for JBEAP-8937 (on Solaris 10/Sparc)
+    if [ -d "${wdir}" ]; then
+      wdir=`cd "$wdir/.."; pwd`
+    fi
+    # end of workaround
+  done
+  echo "${basedir}"
+}
+
+# concatenates all lines of a file
+concat_lines() {
+  if [ -f "$1" ]; then
+    echo "$(tr -s '\n' ' ' < "$1")"
+  fi
+}
+
+BASE_DIR=`find_maven_basedir "$(pwd)"`
+if [ -z "$BASE_DIR" ]; then
+  exit 1;
+fi
+
+##########################################################################################
+# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+# This allows using the maven wrapper in projects that prohibit checking in binary data.
+##########################################################################################
+if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
+    if [ "$MVNW_VERBOSE" = true ]; then
+      echo "Found .mvn/wrapper/maven-wrapper.jar"
+    fi
+else
+    if [ "$MVNW_VERBOSE" = true ]; then
+      echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
+    fi
+    jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
+    while IFS="=" read key value; do
+      case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
+      esac
+    done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
+    if [ "$MVNW_VERBOSE" = true ]; then
+      echo "Downloading from: $jarUrl"
+    fi
+    wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
+
+    if command -v wget > /dev/null; then
+        if [ "$MVNW_VERBOSE" = true ]; then
+          echo "Found wget ... using wget"
+        fi
+        wget "$jarUrl" -O "$wrapperJarPath"
+    elif command -v curl > /dev/null; then
+        if [ "$MVNW_VERBOSE" = true ]; then
+          echo "Found curl ... using curl"
+        fi
+        curl -o "$wrapperJarPath" "$jarUrl"
+    else
+        if [ "$MVNW_VERBOSE" = true ]; then
+          echo "Falling back to using Java to download"
+        fi
+        javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
+        if [ -e "$javaClass" ]; then
+            if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
+                if [ "$MVNW_VERBOSE" = true ]; then
+                  echo " - Compiling MavenWrapperDownloader.java ..."
+                fi
+                # Compiling the Java class
+                ("$JAVA_HOME/bin/javac" "$javaClass")
+            fi
+            if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
+                # Running the downloader
+                if [ "$MVNW_VERBOSE" = true ]; then
+                  echo " - Running MavenWrapperDownloader.java ..."
+                fi
+                ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
+            fi
+        fi
+    fi
+fi
+##########################################################################################
+# End of extension
+##########################################################################################
+
+export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
+if [ "$MVNW_VERBOSE" = true ]; then
+  echo $MAVEN_PROJECTBASEDIR
+fi
+MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+  [ -n "$M2_HOME" ] &&
+    M2_HOME=`cygpath --path --windows "$M2_HOME"`
+  [ -n "$JAVA_HOME" ] &&
+    JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
+  [ -n "$CLASSPATH" ] &&
+    CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
+  [ -n "$MAVEN_PROJECTBASEDIR" ] &&
+    MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
+fi
+
+WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+exec "$JAVACMD" \
+  $MAVEN_OPTS \
+  -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
+  "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
+  ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
diff --git a/mvnw.cmd b/mvnw.cmd
new file mode 100644
index 0000000..fef5a8f
--- /dev/null
+++ b/mvnw.cmd
@@ -0,0 +1,161 @@
+@REM ----------------------------------------------------------------------------
+@REM Licensed to the Apache Software Foundation (ASF) under one
+@REM or more contributor license agreements.  See the NOTICE file
+@REM distributed with this work for additional information
+@REM regarding copyright ownership.  The ASF licenses this file
+@REM to you under the Apache License, Version 2.0 (the
+@REM "License"); you may not use this file except in compliance
+@REM with the License.  You may obtain a copy of the License at
+@REM
+@REM    https://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing,
+@REM software distributed under the License is distributed on an
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@REM KIND, either express or implied.  See the License for the
+@REM specific language governing permissions and limitations
+@REM under the License.
+@REM ----------------------------------------------------------------------------
+
+@REM ----------------------------------------------------------------------------
+@REM Maven2 Start Up Batch script
+@REM
+@REM Required ENV vars:
+@REM JAVA_HOME - location of a JDK home dir
+@REM
+@REM Optional ENV vars
+@REM M2_HOME - location of maven2's installed home dir
+@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
+@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
+@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
+@REM     e.g. to debug Maven itself, use
+@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+@REM ----------------------------------------------------------------------------
+
+@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
+@echo off
+@REM set title of command window
+title %0
+@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
+@if "%MAVEN_BATCH_ECHO%" == "on"  echo %MAVEN_BATCH_ECHO%
+
+@REM set %HOME% to equivalent of $HOME
+if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
+
+@REM Execute a user defined script before this one
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
+@REM check for pre script, once with legacy .bat ending and once with .cmd ending
+if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
+if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
+:skipRcPre
+
+@setlocal
+
+set ERROR_CODE=0
+
+@REM To isolate internal variables from possible post scripts, we use another setlocal
+@setlocal
+
+@REM ==== START VALIDATION ====
+if not "%JAVA_HOME%" == "" goto OkJHome
+
+echo.
+echo Error: JAVA_HOME not found in your environment. >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+:OkJHome
+if exist "%JAVA_HOME%\bin\java.exe" goto init
+
+echo.
+echo Error: JAVA_HOME is set to an invalid directory. >&2
+echo JAVA_HOME = "%JAVA_HOME%" >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+@REM ==== END VALIDATION ====
+
+:init
+
+@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
+@REM Fallback to current working directory if not found.
+
+set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
+IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
+
+set EXEC_DIR=%CD%
+set WDIR=%EXEC_DIR%
+:findBaseDir
+IF EXIST "%WDIR%"\.mvn goto baseDirFound
+cd ..
+IF "%WDIR%"=="%CD%" goto baseDirNotFound
+set WDIR=%CD%
+goto findBaseDir
+
+:baseDirFound
+set MAVEN_PROJECTBASEDIR=%WDIR%
+cd "%EXEC_DIR%"
+goto endDetectBaseDir
+
+:baseDirNotFound
+set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
+cd "%EXEC_DIR%"
+
+:endDetectBaseDir
+
+IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
+
+@setlocal EnableExtensions EnableDelayedExpansion
+for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
+@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
+
+:endReadAdditionalConfig
+
+SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
+set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
+set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
+FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO (
+	IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 
+)
+
+@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
+if exist %WRAPPER_JAR% (
+    echo Found %WRAPPER_JAR%
+) else (
+    echo Couldn't find %WRAPPER_JAR%, downloading it ...
+	echo Downloading from: %DOWNLOAD_URL%
+    powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
+    echo Finished downloading %WRAPPER_JAR%
+)
+@REM End of extension
+
+%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
+if ERRORLEVEL 1 goto error
+goto end
+
+:error
+set ERROR_CODE=1
+
+:end
+@endlocal & set ERROR_CODE=%ERROR_CODE%
+
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
+@REM check for post script, once with legacy .bat ending and once with .cmd ending
+if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
+if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
+:skipRcPost
+
+@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
+if "%MAVEN_BATCH_PAUSE%" == "on" pause
+
+if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
+
+exit /B %ERROR_CODE%
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..1a9dc49
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>org.springframework.boot</groupId>
+		<artifactId>spring-boot-starter-parent</artifactId>
+		<version>2.1.5.RELEASE</version>
+		<relativePath/> <!-- lookup parent from repository -->
+	</parent>
+	<groupId>io.github</groupId>
+	<artifactId>miniurl</artifactId>
+	<version>0.0.1-SNAPSHOT</version>
+	<name>miniurl</name>
+	<description>Demo project for Spring Boot</description>
+
+	<properties>
+		<java.version>11</java.version>
+	</properties>
+
+	<dependencies>
+
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-data-redis-reactive</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-webflux</artifactId>
+		</dependency>
+
+		<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
+		<dependency>
+			<groupId>org.projectlombok</groupId>
+			<artifactId>lombok</artifactId>
+			<version>1.18.0</version>
+			<scope>provided</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-test</artifactId>
+			<scope>test</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>io.projectreactor</groupId>
+			<artifactId>reactor-test</artifactId>
+			<scope>test</scope>
+		</dependency>
+
+	</dependencies>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.springframework.boot</groupId>
+				<artifactId>spring-boot-maven-plugin</artifactId>
+			</plugin>
+		</plugins>
+	</build>
+
+</project>
diff --git a/src/main/java/io/github/miniurl/MiniurlApplication.java b/src/main/java/io/github/miniurl/MiniurlApplication.java
new file mode 100644
index 0000000..ccfc3ad
--- /dev/null
+++ b/src/main/java/io/github/miniurl/MiniurlApplication.java
@@ -0,0 +1,13 @@
+package io.github.miniurl;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class MiniurlApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(MiniurlApplication.class, args);
+    }
+
+}
diff --git a/src/main/java/io/github/miniurl/api/UrlRequestBody.java b/src/main/java/io/github/miniurl/api/UrlRequestBody.java
new file mode 100644
index 0000000..8213f18
--- /dev/null
+++ b/src/main/java/io/github/miniurl/api/UrlRequestBody.java
@@ -0,0 +1,18 @@
+package io.github.miniurl.api;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Positive;
+import java.net.URI;
+import java.util.Optional;
+
+@Data
+@NoArgsConstructor
+public class UrlRequestBody {
+    @NotNull
+    private URI url;
+
+    private Optional<@Positive Long> ttl;
+}
diff --git a/src/main/java/io/github/miniurl/api/UrlResponseBody.java b/src/main/java/io/github/miniurl/api/UrlResponseBody.java
new file mode 100644
index 0000000..d768149
--- /dev/null
+++ b/src/main/java/io/github/miniurl/api/UrlResponseBody.java
@@ -0,0 +1,12 @@
+package io.github.miniurl.api;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+import java.net.URI;
+
+@Data
+@AllArgsConstructor
+public class UrlResponseBody {
+    private final URI url;
+}
diff --git a/src/main/java/io/github/miniurl/controllers/UrlController.java b/src/main/java/io/github/miniurl/controllers/UrlController.java
new file mode 100644
index 0000000..2d683ca
--- /dev/null
+++ b/src/main/java/io/github/miniurl/controllers/UrlController.java
@@ -0,0 +1,20 @@
+package io.github.miniurl.controllers;
+
+import io.github.miniurl.api.UrlRequestBody;
+import io.github.miniurl.api.UrlResponseBody;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+import reactor.core.publisher.Mono;
+
+import javax.validation.Valid;
+import java.net.URI;
+
+@RestController
+public class UrlController {
+
+    @PostMapping
+    public Mono<UrlResponseBody> hashUrl(@RequestBody @Valid UrlRequestBody request) {
+        return Mono.just(new UrlResponseBody(URI.create("localhost.com")));
+    }
+}
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/src/main/resources/application.properties
@@ -0,0 +1 @@
+
diff --git a/src/test/java/io/github/miniurl/MiniurlApplicationTests.java b/src/test/java/io/github/miniurl/MiniurlApplicationTests.java
new file mode 100644
index 0000000..d3fc39e
--- /dev/null
+++ b/src/test/java/io/github/miniurl/MiniurlApplicationTests.java
@@ -0,0 +1,16 @@
+package io.github.miniurl;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class MiniurlApplicationTests {
+
+	@Test
+	public void contextLoads() {
+	}
+
+}
