Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Revel project structure


May 15, 2021 Revel


Table of contents


Install The Revel and Revel applications to GOPATH as required by the go command line tool. (Refer to the "GOPATH Environment Variable" go command document.) )

Example of a project structure

gocode                  GOPATH 目录
  src                   GOPATH src 目录
    revel               Revel 安装目录
      ...
    sample              Revel应用程序根目录
      app               MVC目录
        controllers     控制器
          init.go       
        models          模型
        routes          
        views           模板
      tests             测试
      conf              
        app.conf        默认配置
        routes          路由定义
      messages          国际化
      public            静态文件
        css             CSS files
        js              Javascript files
        images          Image files

app

app stores the source code and templates.

  • app/controllers
  • app/models
  • app/views

Revel Convention:

  • The template file is placed app/views directory
  • The controller files are placed app/controllers directory

In addition, Revel monitors app/ and automatically recompiles when changes are found. app/ the app/directory are not monitored and are recompiled by the developer when necessary.

Revel imports all dependent init() in app/ the beginning of the init() function in the app directory.

controllers/init.go to register interceptor. The execution of init() same package is out of order, so collecting all interceptors is defined into the same file, making it easy for the developer to specify the order in which the interceptors are executed (which can also be used for sequentially sensitive initialization).

conf

conf directory contains the profile of the Revel application, with two main configurations:

  • app.conf the main profile, contains standard configuration parameters.
  • routes routing definition files.

messages

messages directory contains a localized message file.

public

Static resource files are stored in public directory and are supported directly by Web server. Typically, there are three standard subdirectdirects images, CSS, and JavaScript.

The name of the directory is free to use only if it corresponds to the route.