8000 Base path for ApiClient · Issue #1 · Jaguar-dart/client · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Base path for ApiClient #1

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

Closed
jaumard opened this issue Aug 27, 2018 · 8 comments · Fixed by #10
Closed

Base path for ApiClient #1

jaumard opened this issue Aug 27, 2018 · 8 comments · Fixed by #10

Comments

@jaumard
Copy link
Contributor
jaumard commented Aug 27, 2018

Would be nice to be able to do:

/// Example showing how to define an [ApiClient]
@GenApiClient("users")
class UserApi extends _$UserApiClient implements ApiClient {
  final resty.Route base;

  final SerializerRepo serializers;

  UserApi({this.base, this.serializers});

  @GetReq("/:id")
  Future<User> getUserById(String id);

  @PostReq("/")
  Future<User> createUser(@AsJson() User user);

  @PutReq("/:id")
  Future<User> updateUser(String id, @AsJson() User user);

  @DeleteReq("/:id")
  Future<void> deleteUser(String id);

  @GetReq("/")
  Future<List<User>> all({String name, String email});
}
@tejainece
Copy link
Member

Will fix it.

@kevin-sakemaer
Copy link
Member

Why not put it into
@GenApiClient("users", base: "https://other-website.com/")

@jaumard
Copy link
Contributor Author
jaumard commented Aug 28, 2018

@kleak by putting the base here we can't easily add interceptors later right ? because we'll not have the "base" route param to pass to the constructor ?

@kevin-sakemaer
Copy link
Member

If interceptor a annotations based these will not be a problem to get the base url

@jaumard
Copy link
Contributor Author
jaumard commented Aug 28, 2018

But interceptors can be by route, if they become annotation they are now global because you can't know for witch route you want it :/ you loose in granularity

@kevin-sakemaer
Copy link
Member

Do you have different base for one GenApiClient ?

@tejainece
Copy link
Member
tejainece commented Aug 28, 2018

I think, we should keep base member of GenApiClient. In addition we can add path parameter to GenApiClient @GenApiClient(path: "users").

I think the origin part of the url is better left to base member. Then you can use same ApiClient for multiple origins.

Right now, one can add interceptors to base member. There is no way to add them declarative-ly using annotations. A future enhancement. Please, open an issue for this.

@jaumard
Copy link
Contributor Author
jaumard commented Aug 28, 2018

@kleak @tejainece having a path into GenApiClient is exactly what I need, I'm trying to keep Api per domain so each api will have a path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
0