-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
luci-app-example: rewrite RPC side using ucode
Signed-off-by: George Sapkin <[email protected]>
- Loading branch information
1 parent
e845441
commit b27b82a
Showing
7 changed files
with
64 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
248 changes: 0 additions & 248 deletions
248
applications/luci-app-example/root/usr/libexec/rpcd/luci.example
This file was deleted.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
applications/luci-app-example/root/usr/share/rpcd/ucode/example.uc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env ucode | ||
|
||
'use strict'; | ||
|
||
import { cursor } from 'uci'; | ||
|
||
// Rather than parse files in /etc/config, we can use `cursor`. | ||
const uci = cursor(); | ||
|
||
const methods = { | ||
get_sample1: { | ||
call: function() { | ||
const num_cats = uci.get('example', 'animals', 'num_cats'); | ||
const num_dogs = uci.get('example', 'animals', 'num_dogs'); | ||
const num_parakeets = uci.get('example', 'animals', 'num_parakeets'); | ||
const result = { | ||
num_cats, | ||
num_dogs, | ||
num_parakeets, | ||
is_this_real: false, | ||
not_found: null, | ||
}; | ||
|
||
uci.unload(); | ||
return result; | ||
} | ||
}, | ||
|
||
get_sample2: { | ||
call: function() { | ||
const result = { | ||
option_one: { | ||
name: "Some string value", | ||
value: "A value string", | ||
parakeets: ["one", "two", "three"], | ||
}, | ||
option_two: { | ||
name: "Another string value", | ||
value: "And another value", | ||
parakeets: [3, 4, 5], | ||
}, | ||
}; | ||
return result; | ||
} | ||
} | ||
}; | ||
|
||
return { 'luci.example': methods }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters