Orbit Framework 2.0.0
A high-performance asynchronous C++20 HTTP server framework.
Loading...
Searching...
No Matches
Cors.hpp
Go to the documentation of this file.
1#pragma once
4#include <string>
5#include <vector>
6
7namespace orbit::middleware {
8
14 std::vector<std::string> allowed_origins = {"*"};
15 std::vector<std::string> allowed_methods = {"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"};
16 std::vector<std::string> allowed_headers = {"*"};
17 bool allow_credentials = false;
18 int max_age = 86400; // 24 hours default
19};
20
29
42routing::Middleware require_origin(std::vector<std::string> allowed_origins);
43
44} // namespace middleware
routing::Middleware cors(CorsOptions options=CorsOptions{})
Returns a middleware that handles CORS.
Definition HttpRequest.hpp:19
routing::Middleware require_origin(std::vector< std::string > allowed_origins)
Rejects browser requests from origins that are not listed.
std::function< bool(http::HttpRequest &, std::shared_ptr< http::ResponseWriter >)> Middleware
Definition Router.hpp:19
Options for configuring CORS (Cross-Origin Resource Sharing).
Definition Cors.hpp:13
int max_age
Definition Cors.hpp:18
std::vector< std::string > allowed_origins
Definition Cors.hpp:14
std::vector< std::string > allowed_methods
Definition Cors.hpp:15
std::vector< std::string > allowed_headers
Definition Cors.hpp:16
bool allow_credentials
Definition Cors.hpp:17