-
Notifications
You must be signed in to change notification settings - Fork 76
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 Request] Custom per-URL response validation #26
Comments
One way to do this without over-complicating the API would be to allow setting a block that gets called (with the URL that was requested and the response) to perform custom validation of all URLs. This block could return a result like this: enum CustomValidationResult {
/// response for the url was validated successfully
case valid
/// response for the url was determined to be invalid
case invalid
/// perform the default / non-custom validation
case performDefaultValidation
} |
I'm also happy to do the work here. I mostly just want to agree on the idea & API before jumping in :) |
Hi Ben, Sorry for the delay in getting back to you - thanks for the suggestion :) I've been having a think about this as well and one of the things I'm a little concerned about is the main file / class length is beginning to approach a length that will trigger linter warnings so it might be an idea to create a protocol e.g. |
Sounds good to me! Similar behavior though? Custom validator can opt to handle the response or pass it back to the default validation to handle? |
Great 👍🏻 I'd be happy with that solution. |
One thing I thought of was - currently |
Sounds good to me! Will take a crack at this soon |
The initial PR is here: benasher44#1. I'll open a fresh one against this repo with tests once we discuss and also resolve what to do about #27. |
Actually I don't see tests anywhere… would you like some tests added? |
Thanks - I've merged that in now. Apologies, yes you are correct, I've been meaning to add some tests for a long time now but had been a little rushed off my feet. Now that you've reminded me to come back to this, I'll start adding some too. |
I've just created a release 3.2.0 containing your PR 👍🏻 |
Awesome thanks! |
We have some API hosts that have a general health check that we can use to check connectivity, and then we have other hosts that are setup with a special string just for the captive-portal check. As it stands, the current Connectivity API doesn't allow mixing/matching hosts that can return different response, in a strict way. You can accomplish this to some degree with regexp response validation, but the regexp you write may have to be too permissive to allow the different responses.
The text was updated successfully, but these errors were encountered: