HTTP Port 정의
Basic Structure
port:
PortServiceName:
meta: http @url("baseUrl") [@auth("token")]
methods:
methodName:
meta: method @HttpEndpoint(url="endpoint", method="HTTP_METHOD", contentType="content-type")
# 또는 단축 형태
meta: method @get("/endpoint") # GET 메서드
meta: method @post("/endpoint") # POST 메서드
params:
paramName: ParamType [@body]
return: ReturnType
HTTP Annotations
Port-level Annotations
- @url("baseUrl"): HTTP 서버의 기본 URL
- @auth("token"): 기본 인증 토큰 (선택사항)
Method-level Annotations
- @HttpEndpoint: 상세한 HTTP 설정
url: API 엔드포인트 경로method: HTTP 메서드 (GET, POST, PUT, DELETE, PATCH)contentType: Content-Type 헤더 (기본값: application/json)paramNames: 파라미터 이름 목록 (자동 생성)
Shorthand Annotations
- @get("url"): GET 메서드 단축 표기
- @post("url"): POST 메서드 단축 표기
- @put("url"): PUT 메서드 단축 표기
- @delete("url"): DELETE 메서드 단축 표기
Parameter Annotations
- @body: 요청 본문으로 전송할 파라미터 지정
HTTP Port Examples
1. 기본 JSON API 호출
dto:
UserRequest:
meta: dto
fields:
name: string
email: string
UserResponse:
meta: dto
fields:
id: long
name: string
status: string
port:
UserApiAdapter:
meta: http @url("https://api.example.com")
methods:
createUser:
meta: method @post("/users")
params:
body: UserRequest @body
return: UserResponse
getUser:
meta: method @get("/users/{id}")
params:
id: long
return: UserResponse
updateUser:
meta: method @HttpEndpoint(url="/users/{id}", method="PUT", contentType="application/json")
params:
id: long
body: UserRequest @body
return: UserResponse
2. 파일 업로드 (Multipart)
port:
FileUploadAdapter:
meta: http @url("https://api.fileservice.com") @auth("Token abc123")
methods:
uploadFile:
meta: method @HttpEndpoint(url="/upload", method="POST", contentType="multipart/form-data")
params:
body: org.springframework.util.MultiValueMap @body
return: String
uploadUserDocument:
meta: method @post("/users/{userId}/documents")
params:
userId: long
body: org.springframework.util.MultiValueMap @body
return: Map<String, Object>
3. 외부 인증이 필요한 API
port:
PaymentApiAdapter:
meta: http @url("https://api.payment.com") @auth("Bearer sk_test_123")
methods:
processPayment:
meta: method @post("/v1/payments")
params:
body: PaymentRequest @body
return: PaymentResponse
getPaymentStatus:
meta: method @get("/v1/payments/{paymentId}")
params:
paymentId: string
return: PaymentStatusResponse
4. 실제 외부 API 연동 예시 (Parts Catalog)
port:
PartsCatalogAdapter:
meta: http @url("https://api.parts-catalogs.com") @auth("TDTDTD-9800-2A6D1DB6")
methods:
getCatalogs:
meta: method @get("/v1/catalogs/") -- 차량 카탈로그(브랜드) 목록 정보
params:
return: java.util.List
getCarModelList:
meta: method @get("/v1/catalogs/{catalogId}/models") -- 브랜드별 차량 모델 목록 정보
params:
catalogId: String
return: java.util.List<PartInfo>
getCarInfoByVIN:
meta: method @get("/v1/car/info") -- 대차 번호별 정보
params:
q: String -- VIN or FRAME
return: java.util.List