搜索插件、代码仓与 APP 分类

插件详情v1.1.5

shelf_router_generator

一个与 package:build 兼容的构建器,基于源代码注解为 shelf Web 框架生成请求路由器。

AndroidiOSmacOSWindowsLinux
近 30 天下载
2.3万
喜欢数
71
Pub 分数
140

安装插件

flutter pub add shelf_router_generator

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

ShelfRouterGenerator 是 Shelf Web 框架的构建时代码生成器,它从源注解创建请求路由器。它允许开发人员使用简单、可读的注解在 Dart 代码中定义路由,这些注解会在构建阶段被处理,以生成高效的路由逻辑。这种方法减少了样板代码,并通过在编译时捕获路由错误来提高类型安全性。该包与 `package:build` 系统无缝集成,并支持 Dart 运行的所有主要平台。

适合场景

  • 使用注解路由处理程序定义 REST API
  • 生成类型安全的路由映射
  • 在基于书架的服务器中自动化路由器样板代码
  • 启用路由配置的编译时验证
  • 简化 Web 服务中的复杂路由结构

主要特点

  • 基于注解的路由定义
  • 生成时代码生成
  • 类型安全的路由
  • 与包:build 的集成
  • 对平台无关服务器开发的支持

适合对象

  • 使用 Shelf 构建后端服务的开发人员
  • 优先考虑编译时安全的团队
  • 需要最少路由样板的项目
  • 面向多个平台的 Dart 开发者
  • API密集型应用,具有结构化路由

使用建议

  • 需要 build_runner 进行代码生成
  • 与动态路由相比,运行时灵活性有限
  • 需要理解构建系统工作流程
  • 不适用于运行时路由配置
  • 可能会略微增加构建时间

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Build Status

About Shelf

Shelf makes it easy to create and compose web servers and parts of web servers. How?

  • Expose a small set of simple types.
  • Map server logic into a simple function: a single argument for the request, the response is the return value.
  • Trivially mix and match synchronous and asynchronous processing.
  • Flexibility to return a simple string or a byte stream with the same model.

It was inspired by Connect for NodeJS and Rack for Ruby.

See the package:shelf readme for more information.

Packages

Package Description Issues Version
shelf A model for web server middleware that encourages composition and easy reuse. issues pub package
shelf_packages_handler A shelf handler for serving a packages/ directory. issues pub package
shelf_proxy A shelf handler for proxying HTTP requests to another server. issues pub package
shelf_router A convenient request router for the shelf web-framework, with support for URL-parameters, nested routers and routers generated from source annotations. issues pub package
shelf_router_generator A package:build-compatible builder for generating request routers for the shelf web-framework based on source annotations. issues pub package
shelf_static Static file server support for the shelf package and ecosystem. issues pub package
shelf_test_handler A Shelf handler that makes it easy to test HTTP interactions. issues pub package
shelf_web_socket A shelf handler that wires up a listener for every connection. issues pub package
_shelf_compliance HTTP/1.1 compliance and hardening tests. issues (not published)

Publishing automation

For information about our publishing automation and release process, see https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

所属分类

依赖

依赖清单 8 项

源码仓库

使用此插件的项目