Skip to content

Refactor CodableRouter to ease code reuse#1222

Merged
djones6 merged 2 commits intomasterfrom
refactor_codable_router
Feb 28, 2018
Merged

Refactor CodableRouter to ease code reuse#1222
djones6 merged 2 commits intomasterfrom
refactor_codable_router

Conversation

@tunniclm
Copy link
Copy Markdown
Collaborator

@tunniclm tunniclm commented Feb 23, 2018

Description

Remove code duplication in the CodableRouter and expose CodableHelpers as building blocks for extensions to the CodableRouter.

Motivation and Context

While working on a prototype codable authentication extension to the router I needed to write variations of the existing route registration functions from CodableRouter. These functions have a lot of code duplication to begin with, and with this new extension each function would need to be duplicated again to add the variations.

This motivated a refactor of these functions so they could be constructed from building block functions. These could then be exposed for use by router extensions.

How Has This Been Tested?

Automated testing

Checklist:

  • If applicable, I have updated the documentation accordingly.
  • If applicable, I have added tests to cover my changes.

@codecov-io
Copy link
Copy Markdown

codecov-io commented Feb 23, 2018

Codecov Report

Merging #1222 into master will increase coverage by 1.44%.
The diff coverage is 70.79%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1222      +/-   ##
==========================================
+ Coverage   87.93%   89.38%   +1.44%     
==========================================
  Files          38       38              
  Lines        2404     2232     -172     
==========================================
- Hits         2114     1995     -119     
+ Misses        290      237      -53
Flag Coverage Δ
#Kitura 89.38% <70.79%> (+1.44%) ⬆️
Impacted Files Coverage Δ
Sources/Kitura/CodableRouter.swift 78.46% <70.79%> (+4.19%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0e1f01e...47c6963. Read the comment docs.

Copy link
Copy Markdown
Collaborator

@djones6 djones6 left a comment

Choose a reason for hiding this comment

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

This refactor looks great. Please could you add doc for the new helper functions?

@tunniclm
Copy link
Copy Markdown
Collaborator Author

@djones6 Good point! Done.

* If successful, the HTTP status code will be set to `HTTPStatusCode.noContent` and no
* body will be sent.
*
* If failed, the HTTP status code used for the response wll be set to either the
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

typo: wll

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

😢

*
* - Parameter from: The RequestError to map to a HTTPStatusCode
* - Returns: A HTTPStatusCode corresponding to the RequestError http code
* if valid, or HTTPStatusCode.unknown otherwise
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nitpick: Should the code elements here be back-ticked?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes! I just missed them. :(

@djones6
Copy link
Copy Markdown
Collaborator

djones6 commented Feb 28, 2018

Thank you for adding this excellent documentation. Let's get this merged and the (tiny) nitpicks can be addressed later.

@djones6 djones6 merged commit 548a10d into master Feb 28, 2018
@djones6 djones6 deleted the refactor_codable_router branch February 28, 2018 19:00
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