basic implementation of a HTTP web server using rust
- GET
/
- serves as a ping route. responds with200
status code - GET
/echo/{str}
- responds with200
, along with the query passed in place ofstr
- GET
/user-agent
- responds with200
, along with value ofUser-Agent
header - GET
/files/{file}
- checks for a file in the directory passed in the arguments while runningcargo run
. ex:cargo run --directory tmp
and GET/files/abc
-- the server looks for/tmp/abc
. if found, the server responds with200
along with contents of the file or else404
- POST
/files/{file}
- creates a new file in the directory passed in the arguments while runningcargo run
. ex:cargo run --directory tmp
and POST/files/abc
-- the server creates a new file at/tmp/abc
. if succesfully executed, the server responds with201
or else400