Code Monkey home page Code Monkey logo

clientao's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

clientao's Issues

I suggest using MAP contrary switch to declare HTTP calls

Is your feature request related to a problem? Please describe.
While the current code may work well for the simple application that makes only a few HTTP calls, more it may become difficult to maintain and scale as the complexity of the application increases.

Describe the solution you'd like
I intend to add a MAP data structure to store the functions corresponding to each HTTP method, this allows you to add support for new HTTP methods without changing existing code, just add a new entry to Map.

final methodHandlers = <HttpVerb, Future<Response>>{
      HttpVerb.get: _httpClient.get(uri!, headers: headers),
      HttpVerb.post: _httpClient.post(uri!, headers: headers, body: body),
      HttpVerb.put: _httpClient.put(uri!, headers: headers, body: body),
      HttpVerb.patch: _httpClient.patch(uri!, headers: headers, body: body),
      HttpVerb.delete: _httpClient.delete(uri!, headers: headers, body: body),
  };

Describe alternatives you've considered

I have considered in the future using function or methods for each method, making the code reusable for more complex functions, you may consider creating an abstract interface or class that defines a common set of methods or properties that can be implemented or extended by specific classes.

example:

abstract class HttpClient {
  Future<Response> get(Uri url, {Map<String, String>? headers});
}

class RequestHttpClient implements HttpClient {
@override
  Future<Response> get(Uri url, {Map<String, String>? headers}) async {
    return get(url.toString(), options: Options(headers: headers));
  }

}

This implementation can make the code more scalable and reusable for more complex functions in the future.

Add head method

Is your feature request related to a problem? Please describe.
The HEAD method is similar to GET, but is generally faster, because the server needs to send only the headers and not the body of the response, so we can consider its implementation necessary.

Describe the solution you'd like
I intend to add the HEAD method is useful when a client needs to check if a resource exists, if it is accessible, and if the server is available.

For example, a HEAD request before downloading a complete resource, to check if the resource is available and if the user has permission to access it. And many other cases that are also relevant to your implementation.

I have a suggestion regarding using the main branch for all changes.

I suggest that the project has a branch develop, to have more control of the changes, project mentions the use of gitflow.
All changes first go to branch develop where they can be analyzed and tested.

When it was to make a release of a version you could also use gitflow we would have separate branches of the releases that were already made including the tags that will be generated
ex: release/1.0.0 -> tag v1.0.0

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.