2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 09:16:53 +00:00

98_JsonMod.pm: modify file uri behaviour (Forum #133765

git-svn-id: https://svn.fhem.de/fhem/trunk@27660 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
herrmannj 2023-06-06 20:03:18 +00:00
parent 5a0c055792
commit f9346ea0e5

View File

@ -594,12 +594,15 @@ sub JsonMod_ApiRequest {
my $source = $hash->{'CONFIG'}->{'SOURCE'};
# file: correct file:/.. but also accepted file://..
if ($source =~ m/^file:[\/]{1,2}(.+)/) {
# abs: file:/// or file:/
# rel: file:
# non-comform file:// -> rel file:
if ($source =~ m/^file:[\/]{2}(.+)|^file:(.+)/) {
$hash->{'CONFIG'}->{'IN_REQUEST'} = 0;
$hash->{'API_LAST_RES'} = Time::HiRes::time();
my $filename = $1;
my $filename = $1//$2;
# say "filename: $filename";
if (-e $filename) {
my $data;
open(my $fh, '<', $filename) or do {
@ -1889,7 +1892,16 @@ sub listDates {
<ul>
<code>define &lt;name&gt; JsonMod &lt;http[s]:example.com:/somepath/somefile.json&gt;</code>
<br><br>
defines the device and set the source (file:/|http://|https://).
defines the device and set the source (file:|http:|https:|system://).<br>
<br>files example:
<ul>
<li>file:[//]/path/file (absolute)</li>
<li>file:[//]path/file (realtive)</li>
</ul>
<br>system example:
<ul>
<li>system://curl -X POST "https://httpbin.org/anything" -H "Accept: application/json" -H "Content-Type: application/json" -d '{"login":"my_login","password":"my_password"}'</li>
</ul>
</ul>
<br>