1 Star 0 Fork 0

Injection / goStart

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

GoDoc Build Status

goStart

正如项目的名称,你可以从本代码开始你的web api之旅 本项目是用于开发web api的基础代码,包含Router,基础的json序列化等 你可以直接clone一份本代码,然后在此基础上开发你的web api.

#功能:

  • 类似 express 3.x的路由
  • URL参数
  • 基础的json序列化
  • some convenient function

#为什么: 从NodeJs转到go,习惯了使用express框架的我在go中找不到类似的框架,虽然有martin和gin 但是我任然很难习惯,所以就写了一些代码模仿express的功能,让自己尽快的适应go中web api的 开发工作.

#需要做的:

  • Form表达解析(各种MIME)
  • 更丰富的json序列化支持
  • Cookies操作
  • Session支持
  • 中间件
  • 脚手架

#Usage

	handler := NewHanlder()
	handler.AddRouter("/user/login", func(c *context.Context) {
		j := NewJson()
	    j.BeginObject("user")
		j.BeginArray("products")
		j.BeginObject("")
		j.Add("id", "123456")
		j.Add("id", 3.1415926)
		j.EndObject()
		j.EndArray()
		j.EndObject()
		c.Json(j.ToString())
	})
	
	handler.AddRouter("/user/:userid/profile", func(c *context.Context) {
		j := NewJson()
	    j.BeginObject("user")
		j.Add("id", c.Params["userid"])
		j.Add("username", "yourname")
		j.Add("avatar", "http://git.oschina.net/logo.gif")
		j.Add("balance", 3.1415926)
		j.EndObject()
		c.Json(j.ToString())
	})
	handler.Start(":80")

#性能测试

#路由

PASS
BenchmarkRouter	 1000000	      1013 ns/op
ok  	proj	1.064s
The MIT License (MIT) Copyright (c) 2015 hao Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

some base code for make web api 展开 收起
Go
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Go
1
https://gitee.com/tfzxyinhao/goStart.git
git@gitee.com:tfzxyinhao/goStart.git
tfzxyinhao
goStart
goStart
master

搜索帮助