proj

command module
v0.0.0-...-e7825f9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2015 License: MIT Imports: 21 Imported by: 0

README

GoDoc Build Status

简体中文

goStart

This is some basic source code of web api, you can use this source code for making or customizing your own web api


#Why As you all know express framework is very popular in nodejs,and it's also very convenience for web developers and many developers are using them to build applications. now i am moving to golang and i can't find noting similar to nodejs express framework in golang althought it has gin,recel framework etc, but i still can't adjust to it. so i wrote these basic code to providing router that functionality similar to express 3.x

#Feature:

  • base route like express 3.x
  • url param
  • base json serialize
  • some convenient function

#TODO:

  • form parse wrap
  • base json deserialization

#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")

#Benchmark

#Router

PASS
BenchmarkRouter	 1000000	      1013 ns/op
ok  	proj	1.064s

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
this package wrap http request and respone
this package wrap http request and respone

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL