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

Routing : Add logic to separate request query, route and body values for arguments #24

Open
sulton-max opened this issue Apr 4, 2023 · 0 comments
Labels
enhancement New feature or request infrastructure Infrastructure feature

Comments

@sulton-max
Copy link
Contributor

sulton-max commented Apr 4, 2023

Now if query and route has 2 parameters with the same type, request handler will try to create arguments from request based on their type only

    private async ValueTask<object[]> GetArguments(MethodInfo method, HttpListenerContext context)
    {
        var parameters = method.GetParameters();
        var args = new object[parameters.Length];

        for (int i = 0; i < parameters.Length; i++)
        {
            var parameterType = parameters[i].ParameterType;
            if (parameterType == typeof(HttpListenerContext))
            {
                args[i] = context;
            }
            else
            {
                args[i] = null;
            }

            var content = await GetRequestContentAsync(context.Request, parameterType);
            if (content != default)
                args[i] = content;
        }

        return args;
    }
@sulton-max sulton-max changed the title r Routing : Add logic to separate request query, route and body values for arguments Apr 4, 2023
@sulton-max sulton-max added enhancement New feature or request infrastructure Infrastructure feature labels Apr 4, 2023
@dotnetgoo dotnetgoo reopened this Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request infrastructure Infrastructure feature
Projects
None yet
Development

No branches or pull requests

2 participants