@@ -30,7 +30,7 @@ repositories {
30
30
}
31
31
32
32
dependencies {
33
- implementation 'com.github.moia-dev.lambda-kotlin-request-router:router:0.5.0 '
33
+ implementation 'com.github.moia-dev.lambda-kotlin-request-router:router:0.8.2 '
34
34
}
35
35
36
36
```
@@ -99,13 +99,13 @@ override val router = router {
99
99
100
100
private fun loggingFilter () = Filter { next -> {
101
101
request ->
102
- log.info(" Handling request ${request.apiRequest. httpMethod} ${request.apiRequest .path} " )
102
+ log.info(" Handling request ${request.httpMethod} ${request.path} " )
103
103
next(request) }
104
104
}
105
105
106
106
private fun mdcFilter () = Filter { next -> {
107
107
request ->
108
- MDC .put(" requestId" , request.apiRequest. requestContext?.requestId)
108
+ MDC .put(" requestId" , request.requestContext?.requestId)
109
109
next(request) }
110
110
}
111
111
}
@@ -161,6 +161,48 @@ So we do no validation of the JWT token.
161
161
162
162
### Protobuf support
163
163
164
+ The module ` router-protobuf ` helps to ease implementation of handlers that receive and return protobuf messages.
165
+
166
+ ```
167
+ implementation 'com.github.moia-dev.lambda-kotlin-request-router:router-protobuf:0.8.2'
168
+ ```
169
+
170
+ A handler implementation that wants to take advantage of the protobuf support should inherit from ` ProtoEnabledRequestHandler ` .
171
+
172
+ ``` kotlin
173
+ class TestRequestHandler : ProtoEnabledRequestHandler () {
174
+
175
+ override val router = router {
176
+ defaultProducing = setOf (" application/x-protobuf" )
177
+ defaultConsuming = setOf (" application/x-protobuf" )
178
+
179
+ defaultContentType = " application/x-protobuf"
180
+
181
+ GET (" /some-proto" ) { _: Request <Unit > -> ResponseEntity .ok(Sample .newBuilder().setHello(" Hello" ).build()) }
182
+ .producing(" application/x-protobuf" , " application/json" )
183
+ POST (" /some-proto" ) { r: Request <Sample > -> ResponseEntity .ok(r.body) }
184
+ GET <Unit , Unit >(" /some-error" ) { _: Request <Unit > -> throw ApiException (" boom" , " BOOM" , 400 ) }
185
+ }
186
+
187
+ override fun createErrorBody (error : ApiError ): Any =
188
+ io.moia.router.proto.sample.SampleOuterClass .ApiError .newBuilder()
189
+ .setMessage(error.message)
190
+ .setCode(error.code)
191
+ .build()
192
+
193
+ override fun createUnprocessableEntityErrorBody (errors : List <UnprocessableEntityError >): Any =
194
+ errors.map { error ->
195
+ io.moia.router.proto.sample.SampleOuterClass .UnprocessableEntityError .newBuilder()
196
+ .setMessage(error.message)
197
+ .setCode(error.code)
198
+ .setPath(error.path)
199
+ .build()
200
+ }
201
+ }
202
+ ```
203
+
204
+ Make sure you override ` createErrorBody ` and ` createUnprocessableEntityErrorBody ` to map error type to your proto error messages.
205
+
164
206
165
207
### Open API validation support
166
208
@@ -173,7 +215,7 @@ This library validates:
173
215
- ...
174
216
175
217
```
176
- testImplementation 'com.github.moia-dev.lambda-kotlin-request-router:router-openapi-request-validator:0.5.0 '
218
+ testImplementation 'com.github.moia-dev.lambda-kotlin-request-router:router-openapi-request-validator:0.8.2 '
177
219
```
178
220
179
221
``` kotlin
0 commit comments