https://github.com/luopengift/gohttp
go http framework
https://github.com/luopengift/gohttp
gohttp golang http web
Last synced: 2 months ago
JSON representation
go http framework
- Host: GitHub
- URL: https://github.com/luopengift/gohttp
- Owner: luopengift
- License: apache-2.0
- Created: 2017-03-28T07:11:23.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2019-04-18T08:40:13.000Z (almost 7 years ago)
- Last Synced: 2025-08-13T20:41:47.898Z (8 months ago)
- Topics: gohttp, golang, http, web
- Language: Go
- Size: 129 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gohttp
[](https://travis-ci.org/luopengift/gohttp)
[](https://godoc.org/github.com/luopengift/gohttp)
[](https://gowalker.org/github.com/luopengift/gohttp)
[](http://www.apache.org/licenses/LICENSE-2.0.html)
---
gohttp is used for RESTful APIs, Web apps, Http services in Golang.
It is used similar with [Tornado](http://www.tornadoweb.org).
## GO verion
```{.golang .numberLines startFrom="1"}
GOVERSION >= 1.9.0
```
## Getting started
### Sample example
* Simple Server Application: [server](https://github.com/luopengift/gohttp/blob/master/example/server.go)
* Simple Client Application: [client](https://github.com/luopengift/gohttp/blob/master/example/client.go)
### Complete Example
```{.golang .numberLines startFrom="1"}
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
``` {.shell .numberLines startFrom="1"}
go get github.com/luopengift/gohttp
```
#### Generate https tls cert/key file
``` {.shell .numberLines startFrom="1"}
go run $GOROOT/src/crypto/tls/generate_cert.go --host localhost
```
#### Run
``` {.shell .numberLines startFrom="1"}
go run $GOPATH/src/github.com/luopengift/gohttp/sample/server.go
```
## Contributing
1. Fork it
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Added some feature')
4. Push to the branch (git push origin my-new-feature)
5. Create new Pull Request
## Author
[@luopengift](luopengift@foxmail.com)
## License
gohttp source code is licensed under the [Apache Licence 2.0](http://www.apache.org/licenses/LICENSE-2.0.html).