Commit fd81d314 by Patryk Czarnik

prefix URL na poziomie klasy

parent 235591df
......@@ -5,12 +5,14 @@ import java.util.Optional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import sklep.model.Product;
import sklep.repository.ProductRepository;
@RestController
@RequestMapping("/products")
public class ProductEndpoint {
private ProductRepository productRepository;
......@@ -18,12 +20,12 @@ public class ProductEndpoint {
this.productRepository = productRepository;
}
@GetMapping("/products")
@GetMapping
public List<Product> getAllProducts() {
return productRepository.findAll();
}
@GetMapping("/products/{id}")
@GetMapping("/{id}")
public Optional<Product> getOneProduct(@PathVariable("id") Integer id) {
return productRepository.findById(id);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment