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

feat(service): add generic HTTP service #506

Merged
merged 13 commits into from
Jan 17, 2023
Merged

feat(service): add generic HTTP service #506

merged 13 commits into from
Jan 17, 2023

Conversation

nikoksr
Copy link
Owner

@nikoksr nikoksr commented Jan 14, 2023

Description

Adding a generic HTTP service. This service tries to provide common functionalities that would be required by a Notify HTTP service while staying intuitive, lean but powerful.

The service mostly is a wrapper around the standard libraries http package and provides us with some QoL functions, while still following the libraries general practices.

See here for a usage example.

Motivation and Context

As discussed with multiple other devs, we decided to initiate the move away from the heavy SDK dependency over to a leaner but more manual approach. To achieve this we have to implement the services through direct HTTP calls rather than the usage of 3rd-party SDKs.

Implicitly this means that we'd end up with a ton of different implementations and practices when it comes to HTTP communication in Go. To avoid or minimize that, we decided to provide the project with a generalized HTTP service. Additionally, this will help people connect to services with HTTP endpoints that are not (yet) officially supported by Notify.

How Has This Been Tested?

Wrote extensive tests using the net/http/httptest package. I chose the httptest package over our common practice as I like the idea of a full integration test for our most fundamental service better, than to mock it.

The httptest.Server used will run on the lo network interface and we'll thus test against "real" HTTP calls instead of intercepted or emulated ones.

As more and more services will be reimplemented with a manual HTTP approach, it is likely that this is gonna become the projects new standard for service testing, too. It feels like the right step at this point in time.

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 added tests to cover my changes.
  • All new and existing tests passed.

@nikoksr nikoksr added type/feature New feature or request affects/services Issue or PR related to a notification service. labels Jan 14, 2023
@codecov-commenter
Copy link

codecov-commenter commented Jan 14, 2023

Codecov Report

Base: 73.43% // Head: 75.39% // Increases project coverage by +1.95% 🎉

Coverage data is based on head (fcbf222) compared to base (868f04d).
Patch coverage: 92.96% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #506      +/-   ##
==========================================
+ Coverage   73.43%   75.39%   +1.95%     
==========================================
  Files          37       38       +1     
  Lines        1148     1276     +128     
==========================================
+ Hits          843      962     +119     
- Misses        228      234       +6     
- Partials       77       80       +3     
Impacted Files Coverage Δ
service/http/http.go 92.96% <92.96%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@nikoksr nikoksr mentioned this pull request Jan 15, 2023
10 tasks
@nikoksr nikoksr merged commit 440d422 into main Jan 17, 2023
@nikoksr nikoksr deleted the feat/service-http branch January 17, 2023 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects/services Issue or PR related to a notification service. size/XL type/feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants