repositorypackage
0.0.0-20190418084007-7e989b4239c6
Repository: https://github.com/luopengift/gohttp.git
Documentation: pkg.go.dev
# Packages
No description provided by the author
# README
gohttp
gohttp is used for RESTful APIs, Web apps, Http services in Golang. It is used similar with Tornado.
GO verion
GOVERSION >= 1.9.0
Getting started
Sample example
Complete Example
package main
import (
"net/http"
"github.com/luopengift/gohttp"
)
type baz struct {
gohttp.BaseHTTPHandler
}
func (ctx *baz) GET() {
ctx.Output("baz ok")
}
func main() {
app := gohttp.Init()
// register route "/foo"
app.RouteFunc("/foo", func(resp http.ResponseWriter, req *http.Request) {
resp.Write([]byte("foo ok"))
})
// register route "/bar"
app.RouteFunCtx("/bar", func(ctx *gohttp.Context) {
ctx.Output("bar ok")
})
// register route "/baz"
app.Route("/baz", &baz{})
app.Run(":8888")
}
Download and Install
go get github.com/luopengift/gohttp
Generate https tls cert/key file
go run $GOROOT/src/crypto/tls/generate_cert.go --host localhost
Run
go run $GOPATH/src/github.com/luopengift/gohttp/sample/server.go
Contributing
- Fork it
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Added some feature')
- Push to the branch (git push origin my-new-feature)
- Create new Pull Request
Author
License
gohttp source code is licensed under the Apache Licence 2.0.