Skip to content

Refactor duplicate code#700

Merged
yoshuawuyts merged 1 commit intohttp-rs:mainfrom
mendelt:fixes
Dec 24, 2020
Merged

Refactor duplicate code#700
yoshuawuyts merged 1 commit intohttp-rs:mainfrom
mendelt:fixes

Conversation

@mendelt
Copy link
Copy Markdown
Contributor

@mendelt mendelt commented Sep 20, 2020

Description

I refactored away some duplicate code in how middleware is added to endpoints. There is still some duplicate code left between the Route::method and 'Route::all but factoring this out will probably require some lambda magic and will not improve readablilty.

Motivation and Context

A check to see if there was middleware present was done in the same way in several places. This small refactoring moves
that check into the code that adds middleware onto an endpoint. This reduces code duplication and improves readability

How Has This Been Tested?

Middleware has decent test coverage. The tests that touch this piece of code still succeed. This code does not add any functionality so no additional tests should be neccesary.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@mendelt mendelt changed the title Fixes Small refactoring and three tests fixed Sep 20, 2020
@mendelt mendelt changed the title Small refactoring and three tests fixed Refactor duplicate code Sep 28, 2020
Copy link
Copy Markdown
Member

@yoshuawuyts yoshuawuyts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks heaps!

@yoshuawuyts yoshuawuyts merged commit f28cdb4 into http-rs:main Dec 24, 2020
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 this pull request may close these issues.

3 participants