-
-
Notifications
You must be signed in to change notification settings - Fork 345
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
Feature: HttpServer plugins #2354
Conversation
48f39b5
to
d1d673d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pushed some suggested changes to your repo.
Sming/Components/Network/src/Network/Http/Resource/HttpResourcePlugin.h
Outdated
Show resolved
Hide resolved
Sming/Components/Network/src/Network/Http/Resource/HttpEventedResource.h
Outdated
Show resolved
Hide resolved
Sming/Components/Network/src/Network/Http/Resource/HttpEventedResource.cpp
Outdated
Show resolved
Hide resolved
Sming/Components/Network/src/Network/Http/Resource/HttpEventedResource.cpp
Outdated
Show resolved
Hide resolved
Sming/Components/Network/src/Network/Http/Resource/HttpEventedResource.cpp
Outdated
Show resolved
Hide resolved
Sming/Components/Network/src/Network/Http/Resource/HttpEventedResource.cpp
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little concerned about the over-use of delegates in this PR: a virtual event handling class would be simpler and consume less RAM. This class would contain methods corresponding to EventType
. Possibly also replace int
return value with a strong enum class
instead - unless of course the actual value is important.
I'm happy to take a look at this approach if you agree?
Sming/Core/Data/PriorityList.h
Outdated
* | ||
****/ | ||
|
||
#include <Data/LinkedObjectList.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`#include "LinkedObjectList.h"
With pleasure. From this PR I will extract the changes related to the linked list classes and move them to a separate PR that should be merged before this one. |
6e263e3
to
d4a42e0
Compare
This PR was updated and ready for your changes :) |
@slaff To help me better understand, can you give examples of possible uses where the plugin is called after the resource callback? |
Yes, a HTML proxy plugin would be a good candidate. Once the response is ready to be sent a Sming HTML proxy plugin will be attached after the resource.onRequestComplete call and will try to rewrite the URL links. |
Also revert delegate parameter types, not used for plugins there's no need to break compatibility
Use virtual classes for plugins instead of delegates
Co-authored-by: mikee47 <mike@sillyhouse.net>
This PR adds plugin support to the HttpServer.
The plugins allow implementation of things like Http Basic Authentication, IP restrictions and content decoding.
See
samples/HttpServer_Plugins/app/application.cpp
andsamples/HttpServer_Plugins/include/ContentDecoderPlugin.h
to get an idea how the plugins are working.