Tornado 6.5 Documentation
which will be passed to RequestHandler.initialize. Finally, the URLSpec may have a name, which will allow it to be used with RequestHandler.reverse_url. For example, in this fragment the root URL / is mapped an argument is a single value or a list with one element, RequestHandler has distinct methods to allow the application to indicate whether or not it expects a list. For lists, use get_query_arguments and no guarantee that a closed connection can be detected promptly. • get_current_user - see User authentication. • get_user_locale - returns Locale object to use for the current user. • set_default_headers0 码力 | 272 页 | 1.12 MB | 2 月前3Tornado 6.5 Documentation
Queue example - a concurrent web spider Structure of a Tornado web application Templates and UI Authentication and security Running and deploying Web framework tornado.web — RequestHandler and Application syntax Security Internationalization UI modules Authentication and security Cookies and signed cookies User authentication Third party authentication Cross-site request forgery protection DNS Rebinding which will be passed to RequestHandler.initialize. Finally, the URLSpec may have a name, which will allow it to be used with RequestHandler.reverse_url. For example, in this fragment the root URL / is mapped0 码力 | 437 页 | 405.14 KB | 2 月前3Rust 程序设计语言 简体中文版 1.85.0
枚举更为合适且实用。假设我们 要处理 IP 地址。目前被广泛使用的两个主要 IP 标准:IPv4(version four)和 IPv6 (version six)。这是我们的程序可能会遇到的所有可能的 IP 地址类型:所以可以枚举出所有 可能的值,这也正是枚举一词的由来。 任何一个 IP 地址要么是 IPv4 的要么是 IPv6 的,而且不能两者都是。IP 地址的这个特性使得 枚举数据结构非常 枚举数据结构非常适合这个场景,因为枚举值只可能是其中一个变体。IPv4 和 IPv6 从根本上 讲仍是 IP 地址,所以当代码在处理适用于任何类型的 IP 地址的场景时应该把它们当作相同的 类型。 可以通过在代码中定义一个 IpAddrKind 枚举来表现这个概念并列出可能的 IP 地址类型,V4 和 V6。这被称为枚举的变体(variants): enum IpAddrKind { V4, V6 IpAddrKind类型的参数: fn route(ip_kind: IpAddrKind) {} 现在可以使用任一变体来调用这个函数: route(IpAddrKind::V4); route(IpAddrKind::V6); 使用枚举甚至还有更多优势。进一步考虑一下我们的 IP 地址类型,目前没有一个存储实际 IP 地址数据的方法;只知道它是什么类型的。考虑到已经在第五章学习过结构体了,你可能会像0 码力 | 562 页 | 3.23 MB | 9 天前3
共 3 条
- 1