Code Monkey home page Code Monkey logo

Comments (2)

jwChung avatar jwChung commented on June 15, 2024

HttpClient를 가지는 생성자 오버로드로 해결하면 어떨까요? 물론 이때는 HttpClient를 독점적으로 소유하고 있지 않으므로 Dipose하는 건 맞지 않겠네요.

private readonly bool ownsExclusively;

public IamportHttpClient(IOptions<IamportHttpClientOptions> optionsAccessor)
    :this(optionsAccessor, new HttpClient())
{
    this.ownsExclusively = true;
}

public IamportHttpClient(IOptions<IamportHttpClientOptions> optionsAccessor, HttpClient httpClient)
{
    this.HttpClient = httpClient; 
    this.HttpClient.BaseAddress = new Uri(options.BaseUrl, UriKind.Absolute);
    this.HttpClient.DefaultRequestHeaders.Connection.Add("keep-alive");
    ...
}

public HttpClient HttpClient { get; }

public void Dispose()
{
    if(this.ownsExclusively)
        this.httpClient
}

from iamport-rest-client-net.

gongdo avatar gongdo commented on June 15, 2024

@jwChung 의견감사합니다.
곰곰히 생각해봤는데 현재 클라이언트가 인증된 상태인지 여부만 별도로 노출하는 것이 좋을 것 같습니다. IamportHttpClientIsAuthorized속성정도로 제공하면 되겠지요.

HttpClient를 직접 노출하는 것은 사용자코드에서 의도하지 않은 변경을 가할 수 있어서 피하고 싶습니다.

from iamport-rest-client-net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.