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
14
15
16
use ipnet::IpNet;

use crate::{
    extension::{user_group::UserGroup, OriginalIpAddr},
    SgRequestExt,
};

impl UserGroup for IpNet {
    fn is_match(&self, req: &crate::SgRequest) -> bool {
        if let Some(OriginalIpAddr(ip)) = req.extract() {
            self.contains(&ip)
        } else {
            false
        }
    }
}