go-fastweb- Go的MVC框架

网友投稿 558 2022-10-18

go-fastweb- Go的MVC框架

go-fastweb 是 Go 语言实现的一个 MVC 框架。

使用案例:

package mainimport (         "fastweb"         "os" )type Products struct {         fastweb.Controller         Name string         Brand string         Features []string         Specifications []string         Image string }func (p *Products) View(id string) os.Error {         if id == "ah64" {                 p.Name = "RC Apache AH64 4-Channel Electric Helicoper"                 p.Brand = "Colco"                 p.Features = []string{                         "4 channel radio control duel propeller system",                         "Full movement controll: forward, backward, left, right, up and down",                         "Replica design",                         "Revolutionary co-axial rotor technology",                 }                 p.Specifications = []string{                         "Dimensions: L 16 Inches X W 5.5 Inches x H 6.5 Inches",                         "Battery Duration: 10 min",                         "Range: 120 Feet",                 }                 p.Image = "/img/ah64.jpg"         }         return nil }func main() {         a := fastweb.NewApplication()         a.RegisterController(&Products{})         a.Run(":12345") }

and the template of the page body (example/views/products/view.tpl):

{.section Name} Name: {Name}
Manufacturer: {Brand}
{.section Image}
{.end} {.section Features} Features:

    {.repeated section @}
  • {@}
  • {.end}
{.end} {.section specifications} Specifications:
    {.repeated section @}
  • {@}
  • {.end}
{.end} {.or} No product was found. {.end}

Sample Lighttpd Config

$HTTP["host"] =~ "" {         server.document-root = "/home/ivan/go-fastweb/example/htdocs/"         server.error-handler-404 = "/dispatch.fcgi"         fastcgi.server = (                 ".fcgi" => ( "localhost" => (                         "host" => "127.0.0.1",                         "port" => 12345,                         "check-local" => "disable",                  ))) }

Sample Apache Config

        ServerName      fastweb         Documentroot    /home/ivan/go-fastweb/example/htdocs/        ErrorLog /var/log/apache2/fastweb.error.log         LogLevel warn         CustomLog /var/log/apache2/fastweb.access.log combined         ServerSignature On        AddHandler fastcgi-script .fcgi         FastCgiExternalServer /home/ivan/go-fastweb/example/htdocs/dispatch.fcgi -host 127.0.0.1:12345         RewriteEngine On         RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f         RewriteRule ^(.*)$ /dispatch.fcgi [QSA,L]

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:leopard- 简单的 ORM 框架
下一篇:8、泛型程序设计与c++标准模板库2.4列表容器
相关文章

 发表评论

暂时没有评论,来抢沙发吧~