Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into ISSUE-12
Browse files Browse the repository at this point in the history
# Conflicts:
#	backend/src/main/java/com/example/backend/controller/ActorController.java
  • Loading branch information
pavlo-bystrytskyi committed Oct 17, 2024
2 parents cbb2bbd + f2c2e83 commit 7b41344
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import lombok.AllArgsConstructor;
import lombok.NonNull;
import org.jetbrains.annotations.NotNull;
import org.springframework.http.HttpMethod;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.resource.NoResourceFoundException;

import java.util.List;

Expand All @@ -32,6 +34,16 @@ public List<ActorResponse> getByName(@PathVariable @NonNull String prefix) {
return actorService.getActorsByPrefix(prefix).stream().map(ActorResponse::from).toList();
}

/**
* Prevents the frontend fallback response from being returned if the request path is invalid.
*
* @throws NoResourceFoundException
*/
@GetMapping("/autocompletion/")
public void getByNameInvalid() throws NoResourceFoundException {
throw new NoResourceFoundException(HttpMethod.GET, "/api/actor/autocompletion/");
}

@PutMapping
public void update() {
// TODO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import com.example.backend.service.ActorMovieService;
import lombok.AllArgsConstructor;
import lombok.NonNull;
import org.springframework.http.HttpMethod;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.resource.NoResourceFoundException;

import java.util.List;

Expand All @@ -25,4 +27,13 @@ public void addActorById(@PathVariable @NonNull Long movieId, @RequestBody IdReq
public List<ActorResponse> getActorsByMovieId(@PathVariable @NonNull Long movieId) {
return actorMovieService.getActorsByMovieId(movieId).stream().map(ActorResponse::from).toList();
}
}

/**
* Prevents the frontend fallback response from being returned if the request path is invalid.
*
* @throws NoResourceFoundException
*/
@GetMapping("/")
public void getByMovieIdInvalid() throws NoResourceFoundException {
throw new NoResourceFoundException(HttpMethod.GET, "/api/actor-movie/");
}}

0 comments on commit 7b41344

Please sign in to comment.