Status code: 200
Body: List of all configuration fields
Example: curl localhost:8081/config/
Status code: 200
if the field exists, otherwise 404
Body: The value of the specified configuration field
Example: curl localhost:8081/config/logfile
Status code: 200
if the new value has been set, 404
if the field doesn't exist or 400
if the new value is invalid
Body: An error message if the new value is invalid
Example: curl -X PUT localhost:8081/config/filename -d "file.txt"
Attribute name | Value | Position | Usage | Effect |
---|---|---|---|---|
path | String |
struct |
#[choices(path = "myconfig")] |
sets the root path of the configuration HTTP service |
message | String |
struct |
#[choices(message = "Welcome!")] |
sets the root path message (not available with JSON) |
json | struct |
#[choices(json)] |
requests and responses content is in json | |
on_set | Expression |
field |
#[choices(on_set = print_value)] |
invokes an expression in the form expr(&v) where v is the new value (note: the old value is replaced after this call returns) |
skip | field |
#[choices(skip)] |
do not treat this field as a 'configuration field' | |
hide_get | field |
#[choices(hide_get)] |
do not generate the HTTP GET for this field | |
hide_put | field |
#[choices(hide_put)] |
do not generate the HTTP PUT for this field | |
validator | Expression |
field |
#[choices(validator = check_value)] |
invokes an expression in the form expr(&v) -> ChoicesResult<()> where v is the new value; the field's value is updated only if the result is Ok |
rw_lock | struct |
#[choices(rw_lock)] |
generates code to hold the configuration object in an Arc<RwLock<>> instead of an Arc<Mutex<>> . |
Type | Text | Json | Notes |
---|---|---|---|
bool |
✔️ | ✔️ | |
char |
✔️ | ✔️ | |
i128 |
✔️ | ✔️ | |
i16 |
✔️ | ✔️ | |
i32 |
✔️ | ✔️ | |
i64 |
✔️ | ✔️ | |
i8 |
✔️ | ✔️ | |
isize |
✔️ | ✔️ | |
u128 |
✔️ | ✔️ | |
u16 |
✔️ | ✔️ | |
u32 |
✔️ | ✔️ | |
u64 |
✔️ | ✔️ | |
u8 |
✔️ | ✔️ | |
usize |
✔️ | ✔️ | |
f32 |
✔️ | ✔️ | |
f64 |
✔️ | ✔️ | |
String |
✔️ | ✔️ | |
Option<T> |
✔️ | ✔️ | T must be supported |
user defined Type and Type<T, ...> |
✔️ | user must implement the traits ChoicesInput and ChoicesOutput |
|
any Type and Type<T, ...> |
✔️ | type must be serializable and deserializable with serde |