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

refactor(server): use more specific HTTP status codes #262

Merged
merged 3 commits into from
Mar 11, 2024

Conversation

tessus
Copy link
Collaborator

@tessus tessus commented Mar 8, 2024

Description

This change returns a more appropriate status code in 2 cases instead of a generic 500 code:

  • UnsupportedMediaType (if the mime type is on the blacklist)
  • Conflict (if the file already exists)

Motivation and Context

closes #261

How Has This Been Tested?

  • cargo test
  • fixtures

Changelog Entry

### Changed

- Return appropriate HTTP status code instead of 500

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)
  • Documentation (no code change)
  • Refactor (refactoring production code)
  • Other

Checklist:

  • My code follows the code style of this project.
  • I have updated the documentation accordingly.
  • I have formatted the code with rustfmt.
  • I checked the lints with clippy.
  • I have added (in this case changed) tests to cover my changes.
  • All new and existing tests passed.

@tessus tessus requested a review from orhun as a code owner March 8, 2024 22:59
src/server.rs Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Mar 8, 2024

Codecov Report

Attention: Patch coverage is 60.00000% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 82.35%. Comparing base (4987cfe) to head (075fc84).

Files Patch % Lines
src/paste.rs 60.00% 2 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #262      +/-   ##
==========================================
+ Coverage   82.32%   82.35%   +0.02%     
==========================================
  Files          11       11              
  Lines        1228     1224       -4     
==========================================
- Hits         1011     1008       -3     
+ Misses        217      216       -1     
Flag Coverage Δ
unit-tests 82.35% <60.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

src/server.rs Show resolved Hide resolved
Copy link
Owner

@orhun orhun left a comment

Choose a reason for hiding this comment

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

Thanks!

@orhun orhun changed the title refactor(server): use more specific http status codes refactor(server): use more specific HTTP status codes Mar 11, 2024
@orhun orhun merged commit 4774de6 into orhun:master Mar 11, 2024
8 checks passed
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.

Return appropriate HTTP status code instead of 500
3 participants