@@ -134,23 +134,19 @@ control these headers programmatically:
134134[source, java, role="primary"]
135135----
136136{
137- AssetSource www = AssetSource.create(Paths.get("www"));
138- assets("/static/*", new AssetHandler(www)
137+ assets("/static/*", Paths.get("www"))
139138 .setLastModified(false)
140- .setEtag(false)
141- );
139+ .setEtag(false);
142140}
143141----
144142
145143.Kotlin
146144[source, kotlin, role="secondary"]
147145----
148146{
149- val www = AssetSource.create(Paths.get("www"))
150- assets("/static/*", AssetHandler(www)
147+ assets("/static/*", Paths.get("www"))
151148 .setLastModified(false)
152149 .setEtag(false)
153- );
154150}
155151----
156152
@@ -160,21 +156,17 @@ The `maxAge` option set a `Cache-Control` header:
160156[source, java, role="primary"]
161157----
162158{
163- AssetSource www = AssetSource.create(Paths.get("www"));
164- assets("/static/*", new AssetHandler(www)
159+ assets("/static/*", Paths.get("www"))
165160 .setMaxAge(Duration.ofDays(365))
166- );
167161}
168162----
169163
170164.Kotlin
171165[source, kotlin, role="secondary"]
172166----
173167{
174- val www = AssetSource.create(Paths.get("www"))
175- assets("/static/*", AssetHandler(www)
168+ assets("/static/*", Paths.get("www"))
176169 .setMaxAge(Duration.ofDays(365))
177- );
178170}
179171----
180172
@@ -188,8 +180,7 @@ specify a function via javadoc:AssetHandler[cacheControl, java.util.Function]:
188180[source, java, role="primary"]
189181----
190182{
191- AssetSource www = AssetSource.create(Paths.get("www"));
192- assets("/static/*", new AssetHandler(www)
183+ assets("/static/*", Paths.get("www"))
193184 .cacheControl(path -> {
194185 if (path.endsWith("dont-cache-me.html")) {
195186 return CacheControl.noCache(); // disable caching
@@ -200,16 +191,15 @@ specify a function via javadoc:AssetHandler[cacheControl, java.util.Function]:
200191 } else {
201192 return CacheControl.defaults(); // AssetHandler defaults
202193 }
203- })) ;
194+ });
204195}
205196----
206197
207198.Kotlin
208199[source, kotlin, role="secondary"]
209200----
210201{
211- val www = AssetSource.create(Paths.get("www"))
212- assets("/static/*", AssetHandler(www)
202+ assets("/static/*", Paths.get("www"))
213203 .cacheControl {
214204 when {
215205 it.endsWith("dont-cache-me.html") -> CacheControl.noCache() // disable caching
@@ -218,7 +208,7 @@ specify a function via javadoc:AssetHandler[cacheControl, java.util.Function]:
218208 .setMaxAge(Duration.ofDays(365))
219209 else -> CacheControl.defaults() // AssetHandler defaults
220210 }
221- })
211+ }
222212}
223213----
224214
@@ -230,11 +220,10 @@ an exception or generating any other content you want:
230220[source, java, role="primary"]
231221----
232222{
233- AssetSource www = AssetSource.create(Paths.get("www"));
234- assets("/static/*", new AssetHandler(www)
223+ assets("/static/*", Paths.get("www"))
235224 .notFound(ctx -> {
236225 throw new MyAssetException();
237- })) ;
226+ });
238227
239228 error(MyAssetException.class, (ctx, cause, code) -> {
240229 // render MyAssetException as you want
@@ -246,13 +235,12 @@ an exception or generating any other content you want:
246235[source, kotlin, role="secondary"]
247236----
248237{
249- val www = AssetSource.create(Paths.get("www"))
250- assets("/static/*", AssetHandler(www)
251- .notFound { _ ->
238+ assets("/static/*", Paths.get("www"))
239+ .notFound { _ ->
252240 throw MyAssetException()
253- })
254- error(MyAssetException::class) {
241+ }
242+ error(MyAssetException::class) {
255243 // render MyAssetException as you want
256- }
244+ }
257245}
258246----
0 commit comments