Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- reids
- save/update
- 개발 어렵당.ㅠ
- jsonMarshaller
- 노드간 통신
- nGinder
- formik
- OIDC
- 월급루팡 일지
- 7879
- hbase 저장공간 설정
- ㅉ때
- 논블록킹 성능
- jar 배포
- pinpoint 2.5.3
- Loki 로그
- RedirectService
- fake jwt
- pinpoint
- 핀포인트
- Ingress Controller Fake
- LPOS
- UnsupportedOperationException
- Armeria
- 플루터
- R2DBC Paging
- 오블완
- 애자일 싫타
- intellij
- 티스토리챌린지
Archives
- Today
- Total
대머리개발자
아르메리아 End-Point 설정 본문
728x90
애초에 완벽한 요구사항으로 나왔다면 하지만.... 그럴수... 럴수 없기 때문에 늘 확장성을 고민..해야 한다.
뭐 일단 기존 잘 사용하고 있는 기능이고
@Get("/product/{style}/count")
fun findAllAvailableCount(@Param("style")style: String): Mono<ApiResponse>
userId의 값이 필요한 케이스가 생겼다.
@Get("/product/{style}/count")
fun findAvailableCount(@Param("style")style: String, @Param("userId")userId: String?): Mono<ApiResponse> {
해서 추가 @Param을 userId의 물음표로 처리만 하면 될 것 같았는데
기존코드가 안 돌아간다. 아래처럼...
Mandatory parameter/header is missing: userId
결국 두 개의 End-Point를 생성해야 할 것 같은..
@Get("/product/{style}/count/{userId}")
fun findAllAvailableCount(@Param("style")style: String, @Param("userId")userId: String?): Mono<ApiResponse>
나의 목표는 하나의 End-Point로 작성하는 것이다.
아르메리아를 리소를 까 보니께 아래와 같은 친구가 있었다.
@MatchesParam
그래서 최종 리소스는
@Get("/product/{style}/count")
@MatchesParam("userId")
fun findAllAvailableCount(@Param("style")style: String, @Param("userId")userId: String): Mono<ApiResponse> {
return productService.findMyAllAvailableCount(getStyle(style), userId).flatMap {
...
}
}
@Get("/product/{style}/count")
fun findAllAvailableCount(@Param("style")style: String): Mono<ApiResponse> {
return productService.findMyAllAvailableCount(getStyle(style)).flatMap {
...
}
}
EndPoint는 같고 @MatchesParam을 통해서 userId의 유무로!! 갈라치기 하는 것이다.
참고로 아르메리아에서는 @Param은 두 가지(@PathVariable, @RequestParam)역할 모두 하나로 처리 한다..
쓰다 보니 더 깔끔한 방법을 찾았다.
최최초종 리소스..
@Get("/product/{style}/count")
fun findAllAvailableCount(@Param("style")style: String, queryString: QueryParams): Mono<ApiResponse> {
자동으로 QueryParams으로 바인딩 해주네!!! 야호!! 래퍼런스가 없는 것은 얻어 걸려야 해 ㅠ
728x90
'개발이야기 > 코틀린' 카테고리의 다른 글
다시 한번 코루틴 적용해 보자. (8) | 2024.10.09 |
---|---|
armeria aop (6) | 2024.09.10 |
시크릿 컬럼 추가에 대한 말도 안 되는 고민 (0) | 2024.08.05 |
데이터 정규화 (1) | 2024.05.17 |
[코틀린]null 처리 재미지다! (0) | 2024.04.02 |