Skip to content

Commit e7a7487

Browse files
author
Ferenc Hammerl
committed
Add controller with endpoint for listing all
1 parent cb39550 commit e7a7487

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.fhammerl.polls.controllers;
2+
3+
import org.springframework.beans.factory.annotation.Autowired;
4+
import org.springframework.web.bind.annotation.*;
5+
6+
import java.util.List;
7+
8+
import com.fhammerl.polls.repositories.PollRepository;
9+
import com.fhammerl.polls.models.Poll;
10+
11+
@RestController
12+
@RequestMapping("api/v1/polls")
13+
public class PollsController {
14+
@Autowired
15+
private PollRepository pollRepository;
16+
17+
@GetMapping
18+
public List<Poll> list() {
19+
return pollRepository.findAll();
20+
}
21+
}

0 commit comments

Comments
 (0)