Comments (4)
As a user I wouldn't like to have a tool rewriting my config unless I explicitly ask it to do it. I consider configs an addition to a default configuration, something that allows me to personalise the experience. I shouldn't be forced to fill all the fields of a config file. In general in config files you put only things that you want to change so if the config is a valid JSON, but empty or with some fields missing, it should be fine.
from binserve.
Thank You @danmx for raising this issue. The bug is valid but why would a user empty/break their configuration file? If the configuration file isn't valid, binserve
shouldn't run but I definitely agree that it must respond with an error message rather than panic
king.
I will implement a feature where it will rewrite the configuration to secure defaults when it's malformed and exit with a non-zero status code in the next release. 👍
Also, if anybody else wants to get it done sooner:
Write a default JSON schema for the configuration file and compare the input JSON if it matches the scheme or not. You can achieve this with valico.
All the configuration related functions and features are in the config.rs
file.
📚 Resources:
- https://stackoverflow.com/questions/44733603/how-do-i-validate-json-using-an-existing-schema-file-in-rust
- https://github.com/serde-rs/json
- https://github.com/s-panferov/valico
from binserve.
Yeah, I agree, that seems like the ideal implementation! This would require some work but I will definitely implement this in the next release. 👍
There is a required
fields option in the valico library:
"required": [ ]
I will put the required fields in that and omit the optional ones and proceed to serve. Thank You for the suggestion! ❤️👍
from binserve.
This has been fixed!
v0.2.0 Released! 🎉
from binserve.
Related Issues (20)
- Move the ASCII art to a separate file HOT 5
- Writing API docs HOT 5
- Feature request: optional HTTPS support with automatically generated self-signed certificate HOT 4
- Append *.html files with .hbs extension HOT 1
- An optional Minify HTML feature HOT 1
- Store config in the cache HOT 1
- Add reverse-proxy functionality
- Support for handlebars partials HOT 3
- Add some CLI flags for typical config options HOT 2
- v0.2.0 Draft HOT 1
- Simpler run configurations without config file + tls instructions HOT 3
- Configuration file should be taken as an argument
- Write a dedicated documentation page (`DOCUMENTATION.md`)
- Implement rules for static files: custom index file & exclude specific files
- Relative routes on directories served from paths other than `/` is not correctly sorted
- `TcpListener` should implement `SO_REUSEPORT`
- Dockerfile
- Include Cargo.lock in the repository HOT 1
- Custom config location HOT 1
- Windows Version throws 404
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from binserve.