Skip to content

Commit 94fcf55

Browse files
committed
adjust controller to don't repeat path
Signed-off-by: João Oliveira <jaoovit@gmail.com>
1 parent 2a25e3a commit 94fcf55

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/main/java/com/openelements/issues/ApiEndpoint.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
import org.jspecify.annotations.NonNull;
1010
import org.slf4j.Logger;
1111
import org.springframework.web.bind.annotation.GetMapping;
12+
import org.springframework.web.bind.annotation.RequestMapping;
1213
import org.springframework.web.bind.annotation.RequestParam;
1314
import org.springframework.web.bind.annotation.RestController;
1415

1516
@RestController
17+
@RequestMapping("/api/v2")
1618
public class ApiEndpoint {
1719

1820
private final static Logger log = org.slf4j.LoggerFactory.getLogger(ApiEndpoint.class);
@@ -24,19 +26,19 @@ public ApiEndpoint(@NonNull final GitHubCache issueCache) {
2426
}
2527

2628

27-
@GetMapping("/api/v2/contributors")
29+
@GetMapping("/contributors")
2830
public Set<Contributor> getContributors() {
2931
log.info("Getting contributors");
3032
return issueCache.getContributors();
3133
}
3234

33-
@GetMapping("/api/v2/contributors/count")
35+
@GetMapping("/contributors/count")
3436
public long getContributorCount() {
3537
log.info("Getting contributors count");
3638
return issueCache.getContributors().size();
3739
}
3840

39-
@GetMapping("/api/v2/issues")
41+
@GetMapping("/issues")
4042
public Set<Issue> getIssues(
4143
@RequestParam(name = "isAssigned", required = false) Boolean isAssigned,
4244
@RequestParam(name = "isClosed", required = false) Boolean isClosed,
@@ -58,7 +60,7 @@ public Set<Issue> getIssues(
5860
.collect(Collectors.toUnmodifiableSet());
5961
}
6062

61-
@GetMapping("/api/v2/issues/count")
63+
@GetMapping("/issues/count")
6264
public long getIssuesCount(
6365
@RequestParam(name = "isAssigned", required = false) Boolean isAssigned,
6466
@RequestParam(name = "isClosed", required = false) Boolean isClosed,
@@ -68,12 +70,12 @@ public long getIssuesCount(
6870
return getIssues(isAssigned, isClosed, filteredLabels, excludedLabels, filteredLanguages).size();
6971
}
7072

71-
@GetMapping("/api/v2/repositories/stars")
73+
@GetMapping("/repositories/stars")
7274
public long getStarsCount() {
7375
return issueCache.getRepositories().stream().mapToLong(repo -> repo.stars()).sum();
7476
}
7577

76-
@GetMapping("/api/v2/repositories/count")
78+
@GetMapping("/repositories/count")
7779
public long getRepositoryCount() {
7880
return issueCache.getRepositories().size();
7981
}

0 commit comments

Comments
 (0)