开源中国

我们不支持 IE 10 及以下版本浏览器

It appears you’re using an unsupported browser

为了获得更好的浏览体验,我们强烈建议您使用较新版本的 Chrome、 Firefox、 Safari 等,或者升级到最新版本的IE浏览器。 如果您使用的是 IE 11 或以上版本,请关闭“兼容性视图”。
go-fastweb首页、文档和下载 - Go的MVC框架 - 开源中国社区
全部项目分类
我要评价
BSD
Google Go
跨平台
分享
收藏
11 人收藏
收录时间:2012-04-09
go-fastweb 详细介绍

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

使用案例:

package main

import (
       
"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}<br/>
Manufacturer: {Brand}<br/>
{.section Image}
<img src="{Image}"><br/>
{.end}
{.section Features}
Features:<br/>
<ul>
{.repeated section @}
<li>{@}</li>
{.end}
</ul>
{.end}
{.section specifications}
Specifications:<br/
>
<ul>
{.repeated section @}
<li>{@}</li>
{.end}
</ul>
{.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

<VirtualHost *:80>
        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]
</VirtualHost>

大家对 go-fastweb 的评论 (全部 0 条评论)
{{repayCom.userName}}
顶部