Skip to content
This repository was archived by the owner on Mar 18, 2021. It is now read-only.
This repository was archived by the owner on Mar 18, 2021. It is now read-only.

Allow resource controller endpoints to take query params as optional arguments #4

Closed

Description

@itsjoeconway

An endpoint could have optional arguments to automatically grab query parameters. These shouldn't impact routing or which handler gets the query parameters. A signature for a handler could then look like this:

@httpget
Future getThings({String location, String name}) {}

where name and location are names of query parameters (case insensitive) and if they exist, those arguments are populated.

Activity

  1. itsjoeconway commented on Aug 26, 2015

    @itsjoeconway
    ContributorAuthor

    Implemented in 40dc2d8

  2. seanmavley commented on Apr 12, 2019

    @seanmavley

    Good!

    Now, how does one construct the URL?
    example.com/search?limit=5&page=10 how would that be constructed to be optional?

    The routing doc here, https://aqueduct.io/docs/http/routing/ doesn't mention anything about query params routes construction

  3. EddieKamau commented on Apr 13, 2020

    @EddieKamau

    By wrapping an argument in curly brackets:

    @Operation.get()
    Future<Response> foo({@Bind.query('name') String name}) async 
    {}
    

    This is documented here: http://aqueduct.io/docs/http/resource_controller/#optional-bindings

  4. evertonfoz commented on Jun 20, 2020

    @evertonfoz

    @EddieKamau , when I use

    @Operation.get()
    Future<Response> foo({@Bind.query('q') String name}) async {}

    and don´t send any query parameters, I receive the

    The method '[]' was called on null.
    Tried calling: []("q") #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)

    Can you help me please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions