spacegate-kernel 0.2.0-alpha.4

A library-first, lightweight, high-performance, cloud-native supported API gateway
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use std::net::SocketAddr;

use crate::Extract;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[repr(transparent)]
pub struct PeerAddr(pub SocketAddr);

impl Extract for PeerAddr {
    fn extract(req: &hyper::Request<crate::SgBody>) -> Self {
        let peer_addr = req.extensions().get::<PeerAddr>().expect("PeerAddr not found");
        *peer_addr
    }
}