Skip to content
This repository has been archived by the owner on Jun 5, 2021. It is now read-only.

Commit

Permalink
webx framework initialize
Browse files Browse the repository at this point in the history
  • Loading branch information
admpub committed Dec 24, 2015
1 parent 473884f commit 161acb0
Show file tree
Hide file tree
Showing 53 changed files with 389 additions and 388 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2013 - 2014 xweb authors
Copyright (c) 2013 - 2014 webx authors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# xweb
# webx

xweb是一个强大的Go语言web框架
webx是一个强大的Go语言web框架

[English](https://github.com/coscms/xweb/blob/master/README_EN.md)
[English](https://github.com/coscms/webx/blob/master/README_EN.md)

[![Go Walker](http://gowalker.org/api/v1/badge)](http://gowalker.org/github.com/coscms/xweb) [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/go-xweb/xweb/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
[![Go Walker](http://gowalker.org/api/v1/badge)](http://gowalker.org/github.com/coscms/webx) [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/go-webx/webx/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

## 技术支持

Expand All @@ -17,7 +17,7 @@ QQ群:369240307
3. 支持合并静态资源,支持同步更新合并的静态资源;
4. 改进路由注册方式(现在变得更加智能);
5. Server支持限制最大连接数
6. 新增对action新返回类型:xweb.JSON/xweb.JSONP/xweb.XML/xweb.FILE等的支持
6. 新增对action新返回类型:webx.JSON/webx.JSONP/webx.XML/webx.FILE等的支持
7. app支持绑定子域名
8. 改进https服务
9. 其它细微调整
Expand All @@ -29,8 +29,8 @@ QQ群:369240307
* **v0.3.0** : 增加对称加密、XSRF通用接口,更换hook引擎为更加优雅的events引擎
* **v0.2.1** : 自动Binding新增对jquery对象,map和array的支持。
* **v0.2** : 新增 validation 子包,从 [https://github.com/astaxie/beego/tree/master/validation](http://https://github.com/astaxie/beego/tree/master/validation) 拷贝过来。
* **v0.1.2** : 采用 [github.com/coscms/xweb/lib/httpsession](http://github.com/coscms/xweb/lib/httpsession) 作为session组件,API保持兼容;Action现在必须从*Action继承,这个改变与以前的版本不兼容,必须更改代码;新增两个模板函数{{session "key"}} 和 {{cookie "key"}};Action新增函数`MapForm`
* **v0.1.1** : App新增AutoAction方法;Action新增Assign方法;Render方法的模版渲染方法中可以通过T混合传入函数和变量,更新了[快速入门](https://github.com/coscms/xweb/tree/master/docs/intro.md)
* **v0.1.2** : 采用 [github.com/coscms/webx/lib/httpsession](http://github.com/coscms/webx/lib/httpsession) 作为session组件,API保持兼容;Action现在必须从*Action继承,这个改变与以前的版本不兼容,必须更改代码;新增两个模板函数{{session "key"}} 和 {{cookie "key"}};Action新增函数`MapForm`
* **v0.1.1** : App新增AutoAction方法;Action新增Assign方法;Render方法的模版渲染方法中可以通过T混合传入函数和变量,更新了[快速入门](https://github.com/coscms/webx/tree/master/docs/intro.md)
* **v0.1.0** : 初始版本

## 特性
Expand All @@ -46,13 +46,13 @@ QQ群:369240307

在安装之前确认你已经安装了Go语言. Go语言安装请访问 [install instructions](http://golang.org/doc/install.html).

安装 xweb:
安装 webx:

go get github.com/coscms/xweb
go get github.com/coscms/webx

## Examples

请访问 [examples](https://github.com/coscms/xweb/tree/master/examples) folder
请访问 [examples](https://github.com/coscms/webx/tree/master/examples) folder

## 案例

Expand All @@ -61,9 +61,9 @@ QQ群:369240307

## 文档

[快速入门](https://github.com/coscms/xweb/tree/master/docs/intro.md)
[快速入门](https://github.com/coscms/webx/tree/master/docs/intro.md)

源码文档请访问 [GoWalker](http://gowalker.org/github.com/coscms/xweb)
源码文档请访问 [GoWalker](http://gowalker.org/github.com/coscms/webx)

## License
BSD License
Expand Down
16 changes: 8 additions & 8 deletions README_EN.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# xweb
# webx

xweb is a web framework for Go which is based on web.go. It just like Struts for Java.
webx is a web framework for Go which is based on web.go. It just like Struts for Java.

[中文](https://github.com/coscms/xweb/blob/master/README.md)
[中文](https://github.com/coscms/webx/blob/master/README.md)

[![Build Status](https://drone.io/github.com/coscms/xweb/status.png)](https://drone.io/github.com/coscms/xweb/latest) [![Go Walker](http://gowalker.org/api/v1/badge)](http://gowalker.org/github.com/coscms/xweb)
[![Build Status](https://drone.io/github.com/coscms/webx/status.png)](https://drone.io/github.com/coscms/webx/latest) [![Go Walker](http://gowalker.org/api/v1/badge)](http://gowalker.org/github.com/coscms/webx)

## Changelog

Expand All @@ -20,13 +20,13 @@ xweb is a web framework for Go which is based on web.go. It just like Struts for

Make sure you have the a working Go environment. See the [install instructions](http://golang.org/doc/install.html).

To install xweb, simply run:
To install webx, simply run:

go get github.com/coscms/xweb
go get github.com/coscms/webx

## Examples

Please visit [examples](https://github.com/coscms/xweb/tree/master/examples) folder
Please visit [examples](https://github.com/coscms/webx/tree/master/examples) folder

## Case

Expand All @@ -35,7 +35,7 @@ Please visit [examples](https://github.com/coscms/xweb/tree/master/examples) fol

## Documentation

API, Please visit [GoWalker](http://gowalker.org/github.com/coscms/xweb)
API, Please visit [GoWalker](http://gowalker.org/github.com/coscms/webx)


## License
Expand Down
10 changes: 5 additions & 5 deletions action.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package xweb
package webx

import (
"bytes"
Expand All @@ -21,10 +21,10 @@ import (
"strings"
"time"

"github.com/coscms/xweb/lib/httpsession"
"github.com/coscms/xweb/lib/log"
"github.com/coscms/xweb/lib/str"
"github.com/coscms/xweb/lib/uuid"
"github.com/coscms/webx/lib/httpsession"
"github.com/coscms/webx/lib/log"
"github.com/coscms/webx/lib/str"
"github.com/coscms/webx/lib/uuid"
)

type Mapper struct{}
Expand Down
20 changes: 10 additions & 10 deletions app.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package xweb
package webx

import (
"errors"
Expand All @@ -17,10 +17,10 @@ import (
"time"

"github.com/coscms/tagfast"
"github.com/coscms/xweb/lib/httpsession"
"github.com/coscms/xweb/lib/log"
"github.com/coscms/xweb/lib/route"
"github.com/coscms/xweb/lib/tplex"
"github.com/coscms/webx/lib/httpsession"
"github.com/coscms/webx/lib/log"
"github.com/coscms/webx/lib/route"
"github.com/coscms/webx/lib/tplex"
)

var (
Expand Down Expand Up @@ -172,7 +172,7 @@ func (a *App) initApp() {
}
a.FuncMaps["StaticUrl"] = a.StaticUrl
a.FuncMaps["XsrfName"] = XsrfName
a.VarMaps["XwebVer"] = Version
a.VarMaps["webxVer"] = Version

if a.AppConfig.SessionOn {
if a.Server.SessionManager != nil {
Expand Down Expand Up @@ -374,7 +374,7 @@ func (app *App) AddRouter(url string, c interface{}) {
}

tag := t.Field(i).Tag
tagStr := tag.Get("xweb")
tagStr := tag.Get("webx")
methods := map[string]bool{} //map[string]bool{"GET": true, "POST": true}
extensions := map[string]bool{} //map[string]bool{"HTML": true, "JSON": true}
group := map[string]bool{} //map[string]bool{"GET_HTML": true, "POST_JSON": true}
Expand All @@ -383,7 +383,7 @@ func (app *App) AddRouter(url string, c interface{}) {
tags := strings.Split(tagStr, " ")
path := tagStr
length := len(tags)
if length >= 2 { //`xweb:"GET|POST /index"`
if length >= 2 { //`webx:"GET|POST /index"`
meStr = tags[0]
path = tags[1]
if path == "" {
Expand All @@ -396,10 +396,10 @@ func (app *App) AddRouter(url string, c interface{}) {
if matched, _ := regexp.MatchString(`^[A-Z.]+(\|[A-Z]+)*$`, tags[0]); !matched {
//非全大写字母时,判断为网址规则
path = tags[0]
if tags[0][0] != '/' { //`xweb:"index"`
if tags[0][0] != '/' { //`webx:"index"`
path = "/" + actionShortName + "/" + path
}
} else { //`xweb:"GET|POST"`
} else { //`webx:"GET|POST"`
meStr = tags[0]
path = "/" + actionShortName + "/" + name
}
Expand Down
2 changes: 1 addition & 1 deletion conf.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package xweb
package webx

func NewCONF() *CONF {
return &CONF{
Expand Down
2 changes: 1 addition & 1 deletion conversion.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package xweb
package webx

// a struct implements this interface can be convert from request param to a struct
type FromConversion interface {
Expand Down
4 changes: 2 additions & 2 deletions cryptor.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package xweb
package webx

import (
"bytes"
"crypto/aes"
"crypto/cipher"
"github.com/coscms/xweb/lib/str"
"github.com/coscms/webx/lib/str"
"log"
)

Expand Down
10 changes: 5 additions & 5 deletions doc.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Copyright 2013 - 2014 The xweb Authors. All rights reserved.
// Copyright 2013 - 2014 The webx Authors. All rights reserved.
// Use of this source code is governed by a BSD
// license that can be found in the LICENSE file.

/*
Package xweb is a simple and powerful web framework for Go.
Package webx is a simple and powerful web framework for Go.
Installation
Make sure you have installed Go 1.1+ and then:
go get github.com/coscms/xweb
go get github.com/coscms/webx
More usage, please visit https://github.com/coscms/xweb/
More usage, please visit https://github.com/coscms/webx/
*/
package xweb
package webx
36 changes: 18 additions & 18 deletions docs/intro.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# xweb介绍
# webx介绍

xweb是一个基于web.go开发的web框架,目前它和Java框架Struts有些类似。
webx是一个基于web.go开发的web框架,目前它和Java框架Struts有些类似。


# xweb特性
# webx特性

* 在一个可执行程序中多Server,多App的支持
* 简单好用的路由映射方式
Expand All @@ -22,10 +22,10 @@ xweb是一个基于web.go开发的web框架,目前它和Java框架Struts有些

如果我们只需要一个server和一个app,则可以直接调用
```Go
xweb.AddAction
xweb.AutoAction
xweb.AddRouter
xweb.Run
webx.AddAction
webx.AutoAction
webx.AddRouter
webx.Run
```
即可运行服务器。

Expand All @@ -41,7 +41,7 @@ App路由映射其实有两个层次,一个层次是App层,一个App及其

App在创建时调用`NewApp`时必须指定此app的映射规则,挂载到服务器的路径
```Go
app := xweb.NewApp("/main")
app := webx.NewApp("/main")
```

App在添加Action时,可以指定此App下所有Mapper的映射规则,有三个函数:
Expand All @@ -54,7 +54,7 @@ App在添加Action时,可以指定此App下所有Mapper的映射规则,有

```Go
type MainAction struct {
xweb.Action
webx.Action
}

app.AutoAction(&MainAction{})
Expand All @@ -73,9 +73,9 @@ Mapper的路由规则有两种形式:
这时,这个路由即为Mapper的名字,对应执行的方法名为Title(mapper变量名);如:
```Go
type MainAction struct {
xweb.Action
webx.Action

login xweb.Mapper
login webx.Mapper
}

func (this *MainAction) Login() {
Expand Down Expand Up @@ -117,7 +117,7 @@ type Filter interface {

## 自动映射

通常我们通过http.Request.Form来获得从用户中请求到服务器端的数据,这些数据一般都是采用name,value的形式提交的。xweb默认支持自动将这些变量映射到Action的成员中,并且这种映射支持子Struct。例如:
通常我们通过http.Request.Form来获得从用户中请求到服务器端的数据,这些数据一般都是采用name,value的形式提交的。webx默认支持自动将这些变量映射到Action的成员中,并且这种映射支持子Struct。例如:

```Go
type HomeAction struct {
Expand Down Expand Up @@ -177,7 +177,7 @@ func (c *MainAction) Parse() error {
模板中可以使用的函数或者变量来源如下:

1)Go模板自带的模板函数
2)xweb内置的模板函数和变量
2)webx内置的模板函数和变量
3)通过Server.Assign或者MultiAssign添加的函数或者变量
4)通过App.Assign或者MultiAssign添加的函数或者变量
5)通过Action.Assign或者MultiAssign添加的函数或者变量
Expand All @@ -187,9 +187,9 @@ func (c *MainAction) Parse() error {

这个请参见 [https://gowalker.org/text/template](https://gowalker.org/text/template)

## xweb内置的模板函数和变量
## webx内置的模板函数和变量

xweb内置的模板函数和Go模板函数一样,在模板中使用{{funcName ...}}形式调用。内置的变量使用{{.T.}}方式调用。
webx内置的模板函数和Go模板函数一样,在模板中使用{{funcName ...}}形式调用。内置的变量使用{{.T.}}方式调用。

* `IsNil(a interface{}) bool`
判断一个指针是否为空
Expand Down Expand Up @@ -237,9 +237,9 @@ xweb内置的模板函数和Go模板函数一样,在模板中使用{{funcName
获取cookie的指


## 通过xweb.Assign或者MultiAssign添加的函数或者变量
## 通过webx.Assign或者MultiAssign添加的函数或者变量

通过xweb.Assign或者MultiAssign添加的函数或者变量在MainServer的RootApp范围内有效,在模板中使用{{funcName ...}}形式调用函数。变量使用{{.T.}}方式调用。
通过webx.Assign或者MultiAssign添加的函数或者变量在MainServer的RootApp范围内有效,在模板中使用{{funcName ...}}形式调用函数。变量使用{{.T.}}方式调用。

## 通过App.Assign或者MultiAssign添加的函数或者变量

Expand All @@ -255,7 +255,7 @@ Action的公共变量,通过{{.xxx}}的方式调用,公共方法通过{{.xxx


## 模板包含
xweb使用include函数来进行模板包含,而不使用template函数。
webx使用include函数来进行模板包含,而不使用template函数。

* `include(tmpl string) interface{}`
包含另外一个模版
Expand Down
2 changes: 1 addition & 1 deletion error.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package xweb
package webx

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion events.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package xweb
package webx

import (
"sync"
Expand Down
2 changes: 1 addition & 1 deletion examples/.gopmfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[deps]
github.com/coscms/xweb=d:\projects\xweb
github.com/coscms/webx=d:\projects\webx
10 changes: 5 additions & 5 deletions examples/actionmethod.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package main
import (
"fmt"

"github.com/coscms/xweb"
"github.com/coscms/webx"
)

type MainAction struct {
*xweb.Action
*webx.Action

hello xweb.Mapper `xweb:"/(.*)"`
hello webx.Mapper `webx:"/(.*)"`
}

var content string = `
Expand All @@ -28,6 +28,6 @@ func (c *MainAction) Hello(world string) {
}

func main() {
xweb.AddAction(&MainAction{})
xweb.Run("0.0.0.0:9999")
webx.AddAction(&MainAction{})
webx.Run("0.0.0.0:9999")
}
Loading

0 comments on commit 161acb0

Please sign in to comment.