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

inject request and response into controller #13

Merged
merged 1 commit into from
Dec 21, 2023

Conversation

codekeyz
Copy link
Owner

@codekeyz codekeyz commented Dec 21, 2023

Description

We now inject the current Request and Response objects into the controller instance when created. This way it's easy to reference things like headers, body, params and query-params without needing to reflect on the controller instance.

I took inspiration from Rails ApplicationController for this one particularly.

class ClientsController < ApplicationController
  # This action uses query string parameters because it gets run
  # by an HTTP GET request, but this does not make any difference
  # to how the parameters are accessed. The URL for
  # this action would look like this to list activated
  # clients: /clients?status=activated
  def index
    if params[:status] == "activated"
      @clients = Client.activated
    else
      @clients = Client.inactivated
    end
  end

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

@codekeyz codekeyz added the enhancement New feature or request label Dec 21, 2023
@codekeyz codekeyz self-assigned this Dec 21, 2023
Copy link

codecov bot commented Dec 21, 2023

Codecov Report

Attention: 32 lines in your changes are missing coverage. Please review.

Comparison is base (1fe98c2) 42.63% compared to head (d3d8f49) 41.69%.

Files Patch % Lines
yaroo/lib/http/http.dart 0.00% 15 Missing ⚠️
yaroo/lib/src/core.dart 0.00% 11 Missing ⚠️
yaroo/lib/src/_router/definition.dart 16.66% 5 Missing ⚠️
yaroo/lib/src/_reflector/reflector.dart 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #13      +/-   ##
==========================================
- Coverage   42.63%   41.69%   -0.94%     
==========================================
  Files          23       23              
  Lines         692      710      +18     
==========================================
+ Hits          295      296       +1     
- Misses        397      414      +17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@codekeyz codekeyz merged commit e79ae88 into main Dec 21, 2023
2 of 4 checks passed
@codekeyz codekeyz deleted the inject-request-response-into-controller branch December 21, 2023 12:05
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

Successfully merging this pull request may close these issues.

1 participant