Comments (5)
Started work. Follow along here:
Branch:
https://github.com/jamesmunns/coap-rs/tree/coap-router
Diff:
https://github.com/jamesmunns/coap-rs/compare/packet-refactor...jamesmunns:coap-router?expand=1
from coap-rs.
@Covertness I plan to implement this next, after the Copper Pull Request is closed.
from coap-rs.
It sounds good! Many HTTP libraries have it.
from coap-rs.
@jamesmunns Any news about your work? I am currently routing using the following structure:
fn request_handler(req: CoAPRequest) -> Option<CoAPResponse> {
println!("Receive request: {:?}", req);
let uri = get_uri(&req);
if let Some(mut response) = req.response {
// Default payload
let mut code = Responses::NotFound;
let mut resp = "not found".to_owned().into_bytes();
match uri.as_ref() {
"status" => {
code = Responses::Content;
resp = "available".to_owned().into_bytes();
},
"json_status" => {
code = Responses::Content;
resp = "{\"status\": \"available\"}".to_owned().into_bytes();
},
_ => {
}
}
// Customize response payload
response.message.header.code = MessageClass::ResponseType(code);
response.message.payload = resp;
// Return the modified response
return Some(response);
}
// Return the auto-generated response
req.response
}
But a router would be nice!
from coap-rs.
closed. please let me know if anyone want the similar feature. i will implement it.
from coap-rs.
Related Issues (20)
- Generic subject observer (RFC 7641) support HOT 5
- Server::run abruptly returns when a response payload is too large HOT 4
- Observe requests crash server if the client uses an empty vec![] to represent Observe: 0
- Migrate to Rust 2021 edition HOT 1
- Updating observes from server? HOT 10
- Crash when using python aiocoap HOT 2
- Unexpected panic due to network connectivity state HOT 1
- Outdated documentation refrenced HOT 1
- Message IDs and tokens not set HOT 2
- Client: Separate responses not processed HOT 2
- GET, POST etc. with Uri-Host HOT 2
- Blockwise transfer for with a request payload HOT 4
- Server response retransmission due to duplicate client request (duplicate MID) HOT 3
- Update coap-lite dependency HOT 2
- 0.12.2's update of coap-lite is incompatible HOT 1
- No easy way to set options in client requests HOT 8
- The observer implementation and my use case HOT 7
- Mio 1.8.8 incompatible with newer Tokio versions HOT 3
- observe uses hard-coded default receive timeout HOT 1
- Inject/queue a notification for the Server to dispatch HOT 4
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 coap-rs.