10 Star 11 Fork 0

nowayout / SFCWebServer

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
SFCWebServer.go 3.63 KB
一键复制 编辑 原始数据 按行查看 历史
unknown 提交于 2015-01-26 11:31 . long long ago changed
/*
_ooOoo_
o8888888o
88" . "88
(| -_- |)
O\ = /O
____/`---'\____
.' \\| |// `.
/ \\||| : |||// \
/ _||||| -:- |||||- \
| | \\\ - /// | |
| \_| ''\---/'' | |
\ .-\__ `-` ___/-. /
___`. .' /--.--\ `. . __
."" '< `.___\_<|>_/___.' >'"".
| | : `- \`.;`\ _ /`;.`/ - ` : | |
\ \ `-. \_ __\ /__ _/ .-` / /
======`-.____`-.___\_____/___.-`____.-'======
`=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
佛祖保佑 永无BUG
*/
// 佛曰:
// 写字楼里写字间,写字间里程序员;
// 程序人员写程序,又拿程序换酒钱。
// 酒醒只在网上坐,酒醉还来网下眠;
// 酒醉酒醒日复日,网上网下年复年。
// 但愿老死电脑间,不愿鞠躬老板前;
// 奔驰宝马贵者趣,公交自行程序员。
// 别人笑我忒疯癫,我笑自己命太贱;
// 不见满街漂亮妹,哪个归得程序员?
package main
import (
"./common"
"./web"
"encoding/json"
"os"
)
func init() {
file, err := os.Open("config.json")
if err != nil {
panic(err)
}
defer file.Close()
dec := json.NewDecoder(file)
err = dec.Decode(&common.Config)
if err != nil {
panic(err)
}
common.Application.CookieSecret = common.Config["cookie_secret"]
common.Application.SendTo = common.Config["sendto"]
common.ConnectString = "driver={" + common.Config["driver"] + "};server=" +
common.Config["server"] + ";database=" + common.Config["database"] +
";uid=" + common.Config["uid"] + ";pwd=" + common.Config["pwd"]
common.Prd01 = "driver={" + common.Config["driver"] + "};server=" +
common.Config["server"] + ";database=" + common.Config["Antenna"] +
";uid=" + common.Config["uid"] + ";pwd=" + common.Config["pwd"]
common.Prd02 = "driver={" + common.Config["driver"] + "};server=" +
common.Config["server"] + ";database=" + common.Config["Passive"] +
";uid=" + common.Config["uid"] + ";pwd=" + common.Config["pwd"]
common.Prd03 = "driver={" + common.Config["driver"] + "};server=" +
common.Config["server"] + ";database=" + common.Config["Active"] +
";uid=" + common.Config["uid"] + ";pwd=" + common.Config["pwd"]
common.Prd05 = "driver={" + common.Config["driver"] + "};server=" +
common.Config["server"] + ";database=" + common.Config["NWI"] +
";uid=" + common.Config["uid"] + ";pwd=" + common.Config["pwd"]
common.Prd06 = "driver={" + common.Config["driver"] + "};server=" +
common.Config["server"] + ";database=" + common.Config["RF"] +
";uid=" + common.Config["uid"] + ";pwd=" + common.Config["pwd"]
parseUrl()
}
var Web_Method = map[string]func(string, web.Handler){
"Get": common.Application.Get,
"Post": common.Application.Post,
"Put": common.Application.Put,
"Delete": common.Application.Delete,
}
func parseUrl() {
for url, val := range handlers {
function := val[0]
method := val[1:]
for _, mt := range method {
curm := mt.(string)
Web_Method[curm](url, function.(func(*web.Context)))
}
}
}
func initTemplate() {
for _, file := range common.HasBaseTemplates {
tepl := common.ParseTemplates("zh_CN", file)
common.Templates_chn[file] = tepl
}
for _, file := range common.HasBaseTemplates {
tepl := common.ParseTemplates("en_US", file)
common.Templates_eng[file] = tepl
}
}
func main() {
go common.SessionGC()
initTemplate()
common.Application.Run("0.0.0.0:5000")
}
Go
1
https://gitee.com/moyu2004/SFCWebServer.git
git@gitee.com:moyu2004/SFCWebServer.git
moyu2004
SFCWebServer
SFCWebServer
master

搜索帮助