parent
a71562df9f
commit
428fcf697a
5 changed files with 6 additions and 8 deletions
|
@ -1,6 +1,5 @@
|
||||||
use crate::dbs::DB;
|
use crate::dbs::DB;
|
||||||
use crate::err::Error;
|
use crate::err::Error;
|
||||||
use crate::net::head;
|
|
||||||
use crate::net::output;
|
use crate::net::output;
|
||||||
use crate::net::session;
|
use crate::net::session;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
|
@ -112,7 +111,7 @@ pub fn config() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejecti
|
||||||
// ------------------------------
|
// ------------------------------
|
||||||
|
|
||||||
// Specify route
|
// Specify route
|
||||||
opts.or(all).or(one).with(head::cors())
|
opts.or(all).or(one)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------
|
// ------------------------------
|
||||||
|
|
|
@ -54,6 +54,8 @@ pub async fn init() -> Result<(), Error> {
|
||||||
let net = net.with(head::version());
|
let net = net.with(head::version());
|
||||||
// Specify a generic server header
|
// Specify a generic server header
|
||||||
let net = net.with(head::server());
|
let net = net.with(head::server());
|
||||||
|
// Set cors headers on all requests
|
||||||
|
let net = net.with(head::cors());
|
||||||
// Log all requests to the console
|
// Log all requests to the console
|
||||||
let net = net.with(log::write());
|
let net = net.with(log::write());
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::err::Error;
|
use crate::err::Error;
|
||||||
use crate::net::head;
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use std::str;
|
use std::str;
|
||||||
use surrealdb::sql::Value;
|
use surrealdb::sql::Value;
|
||||||
|
@ -20,7 +19,7 @@ pub fn config() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejecti
|
||||||
.and(warp::body::bytes())
|
.and(warp::body::bytes())
|
||||||
.and_then(handler);
|
.and_then(handler);
|
||||||
// Specify route
|
// Specify route
|
||||||
opts.or(post).with(head::cors())
|
opts.or(post)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handler(body: Bytes) -> Result<impl warp::Reply, warp::Rejection> {
|
async fn handler(body: Bytes) -> Result<impl warp::Reply, warp::Rejection> {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::err::Error;
|
use crate::err::Error;
|
||||||
use crate::net::head;
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use std::str;
|
use std::str;
|
||||||
use surrealdb::sql::Value;
|
use surrealdb::sql::Value;
|
||||||
|
@ -20,7 +19,7 @@ pub fn config() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejecti
|
||||||
.and(warp::body::bytes())
|
.and(warp::body::bytes())
|
||||||
.and_then(handler);
|
.and_then(handler);
|
||||||
// Specify route
|
// Specify route
|
||||||
opts.or(post).with(head::cors())
|
opts.or(post)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handler(body: Bytes) -> Result<impl warp::Reply, warp::Rejection> {
|
async fn handler(body: Bytes) -> Result<impl warp::Reply, warp::Rejection> {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use crate::dbs::DB;
|
use crate::dbs::DB;
|
||||||
use crate::err::Error;
|
use crate::err::Error;
|
||||||
use crate::net::head;
|
|
||||||
use crate::net::output;
|
use crate::net::output;
|
||||||
use crate::net::session;
|
use crate::net::session;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
|
@ -30,7 +29,7 @@ pub fn config() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejecti
|
||||||
.and(session::build())
|
.and(session::build())
|
||||||
.map(|ws: Ws, session: Session| ws.on_upgrade(move |ws| socket(ws, session)));
|
.map(|ws: Ws, session: Session| ws.on_upgrade(move |ws| socket(ws, session)));
|
||||||
// Specify route
|
// Specify route
|
||||||
opts.or(post).or(sock).with(head::cors())
|
opts.or(post).or(sock)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handler(
|
async fn handler(
|
||||||
|
|
Loading…
Reference in a new issue