Skip to content
Snippets Groups Projects
Commit b5cd9334 authored by David Huss's avatar David Huss :speech_balloon:
Browse files

Update Doc Header and accept OPTIONS requests

parent 3f77205a
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,11 @@ ...@@ -7,6 +7,11 @@
//! curl --header "Content-Type: application/json" --request POST --data '{"name":"Mr. Foo Bar", "email":"mrfoo@bar.com", "phone":"+49012345678", "message":"Media is the massage", "identifier":"mysiteidentifier"}' http://localhost:8088 //! curl --header "Content-Type: application/json" --request POST --data '{"name":"Mr. Foo Bar", "email":"mrfoo@bar.com", "phone":"+49012345678", "message":"Media is the massage", "identifier":"mysiteidentifier"}' http://localhost:8088
//! ``` //! ```
//! //!
//! Or if you want to view the returned headers:
//! ```Bash
//! curl -sSL -D - --header "Content-Type: application/json" --request POST --data '{"name":"Mr. Foo Bar", "email":"mrfoo@bar.com", "phone":"+49012345678", "message":"Media is the massage", "identifier":"mysiteidentifier"}' http://localhost:8088 -o /dev/null
//! ```
//!
//! This emulates a user with the name "Mr. Foo Bar", the email "mrfoo@bar.com" and the phone number "+49012345678" writing a message with the content "Media is the massage". //! This emulates a user with the name "Mr. Foo Bar", the email "mrfoo@bar.com" and the phone number "+49012345678" writing a message with the content "Media is the massage".
//! Note the field `"identifier":"mysitename"` – this identifies the site against the server. If there is no endpoint with the identifier "mysiteidentifier" in the `config.toml`, the request is ignored. //! Note the field `"identifier":"mysitename"` – this identifies the site against the server. If there is no endpoint with the identifier "mysiteidentifier" in the `config.toml`, the request is ignored.
//! This message is checked for type and length, and will be sent via SMTP to the according `endpoint.target` email adress specified in the config. //! This message is checked for type and length, and will be sent via SMTP to the according `endpoint.target` email adress specified in the config.
...@@ -110,7 +115,7 @@ async fn main() -> std::io::Result<()> { ...@@ -110,7 +115,7 @@ async fn main() -> std::io::Result<()> {
for endpoint in Config::new().endpoints { for endpoint in Config::new().endpoints {
cors = cors.allowed_origin(endpoint.domain.clone().as_str()); cors = cors.allowed_origin(endpoint.domain.clone().as_str());
} }
cors = cors.allowed_methods(vec!["GET", "POST"]) cors = cors.allowed_methods(vec!["GET", "POST", "OPTIONS"])
.allowed_headers(vec![http::header::AUTHORIZATION, http::header::ACCEPT]) .allowed_headers(vec![http::header::AUTHORIZATION, http::header::ACCEPT])
.allowed_header(http::header::CONTENT_TYPE) .allowed_header(http::header::CONTENT_TYPE)
.max_age(3600); .max_age(3600);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment