Skip to content

Commit

Permalink
Controller endpoint changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vimal-knoldus committed Oct 13, 2023
1 parent f9a52fd commit c7f2b1e
Showing 1 changed file with 0 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.codec.ServerSentEvent;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

import java.util.Map;

/**
* Rest Controller class
* which handles reactive data access for cars.
Expand Down Expand Up @@ -70,25 +67,6 @@ public Flux<Car> getCarsByBrand(
return reactiveDataService.getCarsByBrand(brand);
}

/**
* Retrieves a stream of cars with the given brand.
* The data is obtained using the reactive service and duplicates
* are filtered out.
*
* @param brand The brand of cars to filter by.
* @return A Flux of Car representing cars with the
* specified brand.
*/
@Operation(summary = "Retrieves cars filtered by brand.",
description = "The data is obtained using the reactive service"
+ " and duplicates are filtered out.")
@GetMapping(value = "/cars-sse/{brand}", produces =
MediaType.TEXT_EVENT_STREAM_VALUE)
public Flux<Car> getCarsByBrandSse(
@PathVariable final String brand) {
return reactiveDataService.getCarsByBrand(brand);
}

/**
* Retrieves a stream of distinct car brands.
* The data is obtained using the reactive service and duplicates are
Expand All @@ -104,27 +82,4 @@ public Flux<Car> getCarsByBrandSse(
public Flux<CarBrand> getAllBrands() {
return reactiveDataService.getAllBrands();
}


/**
* Retrieves a stream of distinct car brands.
*
* The data is obtained using the reactive service and duplicates are
* filtered out.
*
* @return A Flux of CarBrand representing distinct car brands.
*/
@Operation(summary = "Retrieves unique car brands.",
description = "The data is obtained using the reactive"
+ " service and duplicates are filtered out.")
@GetMapping(value = "/brands-sse",
produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public Flux<ServerSentEvent<Map<String, String>>> getAllBrandsSSE() {
return reactiveDataService.getAllBrandsSse()
.map(eventData -> ServerSentEvent.<Map<String, String>>builder()
.data(eventData.data())
.build());
}


}

0 comments on commit c7f2b1e

Please sign in to comment.