Skip to content

Commit

Permalink
#867 - Reenable default encoders and encoders.
Browse files Browse the repository at this point in the history
Thanks to spring-projects/spring-framework#22612, Spring HATEAOAS no longer has to disable the default registry of encoders and decoders to get its custom components to work.

Related issues: #885, spring-projects/spring-framework#22612
  • Loading branch information
gregturn committed Apr 3, 2019
1 parent 110bf62 commit fc3767b
Showing 1 changed file with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.config;

import lombok.RequiredArgsConstructor;
Expand All @@ -7,10 +22,8 @@
import java.util.List;

import org.springframework.context.annotation.Configuration;
import org.springframework.core.codec.CharSequenceEncoder;
import org.springframework.core.codec.Decoder;
import org.springframework.core.codec.Encoder;
import org.springframework.core.codec.StringDecoder;
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
import org.springframework.http.codec.json.Jackson2JsonDecoder;
import org.springframework.http.codec.json.Jackson2JsonEncoder;
Expand Down Expand Up @@ -52,15 +65,11 @@ public ExchangeStrategies hypermediaExchangeStrategies() {
decoders.add(new Jackson2JsonDecoder(objectMapper, mimeTypes));
});

encoders.add(CharSequenceEncoder.allMimeTypes());
decoders.add(StringDecoder.allMimeTypes());

return ExchangeStrategies.builder().codecs(clientCodecConfigurer -> {

encoders.forEach(encoder -> clientCodecConfigurer.customCodecs().encoder(encoder));
decoders.forEach(decoder -> clientCodecConfigurer.customCodecs().decoder(decoder));

clientCodecConfigurer.registerDefaults(false);
}).build();
}

Expand Down

0 comments on commit fc3767b

Please sign in to comment.