Skip to content
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

[network] Decorators #1

Open
5 tasks
SergeShkurko opened this issue Mar 12, 2019 · 0 comments
Open
5 tasks

[network] Decorators #1

SergeShkurko opened this issue Mar 12, 2019 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@SergeShkurko
Copy link
Member

SergeShkurko commented Mar 12, 2019

Package name
network

Describe the solution you'd like
The ability to use decorators for example: @get('http://todo.api/todo/1') / @post('http://todo.api/todo')

Additional context
Proposal example:

class TodoApi {
  @get<JsonApiRequest, JsonApiResponse>('http://todo.api/todo')
  Future<Iterable<Todo>> getAll(JsonApiRequest request, JsonApiResponse response) async {
    return List.from(response.toMap).map((map) => Todo.fromMap(map));
  }

  @get<JsonApiRequest, JsonApiResponse>('http://todo.api/todo/${id}')
  Future<Todo> get(JsonApiRequest request, JsonApiResponse response) async {
    return Todo.fromMap(response.toMap);
  }

  @delete<JsonApiRequest, JsonApiResponse>('http://todo.api/todo/${id}')
  Future<Todo> delete(JsonApiRequest request, JsonApiResponse response) async {
    return response.toMap['success'] != null;
  }
}

TODO

  • JsonApiRequest
  • Get
  • Post
  • Delete
  • Put
@SergeShkurko SergeShkurko added the enhancement New feature or request label Mar 12, 2019
@SergeShkurko SergeShkurko self-assigned this Mar 12, 2019
@SergeShkurko SergeShkurko changed the title ] [network] Decorators Mar 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant