Skip to content

beego 的 MVC 架构控制器创建问题 #975

@leellun

Description

@leellun

每一次请求都要去实例化一个控制器,是不是太奢侈了,作者是不是可以参考一下spring bean的声明周期,或者gin的参考下,每一次请求都去创建一个controller,个人觉得不是太有必要,开发中很少有把状态化数据对象放到controller上,如果有也多半是程序员的不规范,可以选择多种模式,spring的singleton、request或者prototype等多种模式,至少提供一种单例控制器。
好处:
(1)减少资源浪费,提升性能
(2)结合市面上的依赖注入全局管理所有controller、service、dao以及其它结构体实例
(3)规范化代码

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions