Skip to content

Commit

Permalink
fix(media-streaming): correct route bean factory
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnymillergh committed Oct 20, 2020
1 parent 888eb2c commit bd9874e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 38 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.jmframework.boot.mediastreamingspringbootautoconfigure.configuration;

import com.jmframework.boot.mediastreamingspringbootautoconfigure.api.VideoRoutes;
import com.jmframework.boot.mediastreamingspringbootautoconfigure.handler.MediaStreamingExceptionHandler;
import com.jmframework.boot.mediastreamingspringbootautoconfigure.handler.VideoRouteHandler;
import com.jmframework.boot.mediastreamingspringbootautoconfigure.repository.VideoRepository;
Expand All @@ -15,9 +14,16 @@
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.server.RequestPredicate;
import org.springframework.web.reactive.function.server.RequestPredicates;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.ServerResponse;

import javax.annotation.PostConstruct;

import static org.springframework.web.reactive.function.server.RequestPredicates.path;
import static org.springframework.web.reactive.function.server.RouterFunctions.route;

/**
* Description: MediaStreamingAutoConfiguration, change description here.
*
Expand Down Expand Up @@ -60,10 +66,14 @@ public VideoRouteHandler videoRouteHandler(VideoService videoService, FileServic
}

@Bean
@ConditionalOnMissingBean
public VideoRoutes videoRoutes() {
log.info("videoRoutes");
return new VideoRoutes();
public RouterFunction<ServerResponse> videoEndPoint(VideoRouteHandler videoRouteHandler) {
log.info("videoEndPoint");
return route()
.nest(path("/videos"), builder -> builder.GET("", videoRouteHandler::listVideos)
.nest(path("/{name}"), videoBuilder -> videoBuilder.GET("", param("partial"),
videoRouteHandler::getPartialContent).GET("", videoRouteHandler::getFullContent)
)
).build();
}

@Bean
Expand All @@ -83,4 +93,9 @@ public FileService fileService() {
public VideoRepository videoRepository() {
return new InMemoryVideoRepository();
}

@SuppressWarnings("SameParameterValue")
private static RequestPredicate param(String parameter) {
return RequestPredicates.all().and(request -> request.queryParam(parameter).isPresent());
}
}

0 comments on commit bd9874e

Please sign in to comment.