-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Swagger + Octet/Stream 문제 상황에 대해 더 명확한 이해를 가지고 이를 녹여낼 수 있는 구조로 코드 리팩토링
- Loading branch information
1 parent
3988639
commit 851179f
Showing
3 changed files
with
58 additions
and
43 deletions.
There are no files selected for viewing
43 changes: 0 additions & 43 deletions
43
src/main/java/com/stream/configuration/HttpMsgConverterConfig.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.stream.configuration; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.http.converter.HttpMessageConverter; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
import com.stream.msgconverter.OctetStreamReadMsgConverter; | ||
|
||
@Configuration | ||
public class WebConfig implements WebMvcConfigurer { | ||
private OctetStreamReadMsgConverter octetStreamReadMsgConverter; | ||
|
||
@Autowired | ||
public WebConfig(OctetStreamReadMsgConverter octetStreamReadMsgConverter) { | ||
this.octetStreamReadMsgConverter = octetStreamReadMsgConverter; | ||
} | ||
|
||
@Override | ||
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { | ||
converters.add(octetStreamReadMsgConverter); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/com/stream/msgconverter/OctetStreamReadMsgConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.stream.msgconverter; | ||
|
||
import java.lang.reflect.Type; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter; | ||
import org.springframework.stereotype.Component; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
@Component | ||
public class OctetStreamReadMsgConverter extends AbstractJackson2HttpMessageConverter { | ||
@Autowired | ||
public OctetStreamReadMsgConverter(ObjectMapper objectMapper) { | ||
super(objectMapper, MediaType.APPLICATION_OCTET_STREAM); | ||
} | ||
|
||
@Override | ||
public boolean canWrite(Class<?> clazz, MediaType mediaType) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean canWrite(Type type, Class<?> clazz, MediaType mediaType) { | ||
return false; | ||
} | ||
|
||
@Override | ||
protected boolean canWrite(MediaType mediaType) { | ||
return false; | ||
} | ||
} |