Skip to content

Commit

Permalink
Add route for index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
TheKojuEffect committed Oct 25, 2017
1 parent f5149b5 commit 00bd1d6
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/main/java/com/kapilkoju/nepse/data/ApplicationRoutes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.kapilkoju.nepse.data;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.ServerResponse;

import static org.springframework.web.reactive.function.server.RequestPredicates.GET;
import static org.springframework.web.reactive.function.server.RouterFunctions.route;
import static org.springframework.web.reactive.function.server.ServerResponse.ok;

@Configuration
public class ApplicationRoutes {

// TODO: Not required after https://github.com/spring-projects/spring-boot/issues/9785
@Bean
public RouterFunction<ServerResponse> indexRouter(@Value("classpath:/static/index.html") final Resource indexHtml) {
return route(GET("/"),
request -> ok().contentType(MediaType.TEXT_HTML)
.syncBody(indexHtml));
}
}

0 comments on commit 00bd1d6

Please sign in to comment.