New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(feat): NCNetwork : baseUrl 기능 추가 #7
(feat): NCNetwork : baseUrl 기능 추가 #7
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
baseUrl이 설정된 상태에서 baseUrl을 기반으로 하지 않는 URL과 통신해야 할 때는 어떻게 해야 하나요?
src/IO/network/NCNetwork.ts
Outdated
@@ -10,6 +10,12 @@ import { NCNetworkException } from "./NCNetworkException"; | |||
export class NCNetwork { | |||
private network: NCNetworking = Inject(NCNetworkingClassName); | |||
|
|||
constructor(baseUrl?: string) { | |||
if (baseUrl?.trim()) { | |||
this.network.setNewBaseUrl(baseUrl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
유효성을 판단할때는 trim을 하는데, set할 때는 trim을 안하나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setNewBaseUrl()에서 baseUrl을 trim() 처리해서 사용하도록 수정했습니다.
this.network.setNewBaseUrl(baseUrl?.trim());
@iamchiwon-ncode new NCNetwork()에는 아무 값도 넣지 않으면 baseUrl이 사용되기 때문에, 일부러 빈 문자열을 넣어주고 constructor에서 trim()을 if로 판단하는 로직을 제거한다면 baseUrl을 빈 문자열로 교체할 수 있겠습니다. 이렇게 되면 AxiosNetworking.execute()에서 config의 url을 |
// baseUrl 을 사용하고 싶을 때
new NCNetwork().get('/path');
// custom Url 을 사용하고 싶을 때
new NCNetwork().get("http://other"); 이렇게 사용하고 싶은겁니다. 지금 구현으로는 서버를 바꿔가면서 계속 baseUrl이 덮어씌워지니까 매번 full path를 사용해야 하는 상황이죠. |
테스트 코드를 추가해서 커밋했습니다. |
@iamchiwon-ncode 앞선 커밋의 코드를 수정하여, example에서 테스트코드를 작성했습니다. |
…working()을 직접 사용하도록 테스트코드를 수정
작업내용