https://github.com/jmhobbs/gopher
A Gopher protocol library for Go
https://github.com/jmhobbs/gopher
go golang gopher server toy
Last synced: 10 months ago
JSON representation
A Gopher protocol library for Go
- Host: GitHub
- URL: https://github.com/jmhobbs/gopher
- Owner: jmhobbs
- Created: 2019-03-03T03:24:45.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-03T03:31:02.000Z (over 7 years ago)
- Last Synced: 2025-03-01T00:59:05.977Z (over 1 year ago)
- Topics: go, golang, gopher, server, toy
- Language: Go
- Size: 4.88 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://travis-ci.org/jmhobbs/gopher) [](https://codecov.io/gh/jmhobbs/gopher) [](https://godoc.org/github.com/jmhobbs/gopher)
# Gopher Go
This is a toy library for implementing gopher protocol servers in Go.
It's loosely structured after net/http and is api unstable.
# Usage
s := gopher.Server{}
h := gopher.HandleFunc(func(resp gopher.Response, req gopher.Request) {
resp.WriteMenu(gopher.Menu{[]gopher.Link{
gopher.Link{gopher.TextFile, "About", "/about", "localhost", 7070},
gopher.Link{gopher.FullTextSearch, "Search", "/search", "localhost", 7070},
}})
resp.Write([]byte("Welcome to my Gopher hole!"))
resp.End()
}
s.ListenAndServe("127.0.0.1:7070", h))