Product Promotion
0x5a.live
for different kinds of informations and explorations.
GitHub - aliuygur/gores: Go package that handles HTML, JSON, XML and etc. responses
Go package that handles HTML, JSON, XML and etc. responses - aliuygur/gores
Visit SiteGitHub - aliuygur/gores: Go package that handles HTML, JSON, XML and etc. responses
Go package that handles HTML, JSON, XML and etc. responses - aliuygur/gores
Powered by 0x5a.live ๐
gores
http response utility library for Go
this package is very small and lightweight, useful for RESTful APIs.
installation
go get github.com/alioygur/gores
requirements
gores library requires Go version >=1.7
usage
package main
import (
"log"
"net/http"
"github.com/alioygur/gores"
)
type User struct {
Name string
Email string
Age int
}
func main() {
// Plain text response
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
gores.String(w, http.StatusOK, "Hello World")
})
// HTML response
http.HandleFunc("/html", func(w http.ResponseWriter, r *http.Request) {
gores.HTML(w, http.StatusOK, "<h1>Hello World</h1>")
})
// JSON response
http.HandleFunc("/json", func(w http.ResponseWriter, r *http.Request) {
user := User{Name: "Ali", Email: "[email protected]", Age: 28}
gores.JSON(w, http.StatusOK, user)
})
// File response
http.HandleFunc("/file", func(w http.ResponseWriter, r *http.Request) {
err := gores.File(w, r, "./path/to/file.html")
if err != nil {
log.Println(err.Error())
}
})
// Download file
http.HandleFunc("/download-file", func(w http.ResponseWriter, r *http.Request) {
err := gores.Download(w, r, "./path/to/file.pdf", "example.pdf")
if err != nil {
log.Println(err.Error())
}
})
// No content
http.HandleFunc("/no-content", func(w http.ResponseWriter, r *http.Request) {
gores.NoContent(w)
})
// Error response
http.HandleFunc("/error", func(w http.ResponseWriter, r *http.Request) {
gores.Error(w, http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError))
})
err := http.ListenAndServe(":8000", nil)
if err != nil {
log.Fatal("ListenAndServe: ", err)
}
}
for more documentation godoc
Contribute
Use issues for everything
- Report problems
- Discuss before sending a pull request
- Suggest new features/recipes
- Improve/fix documentation
Thanks & Authors
I use code/got inspiration from these excellent libraries:
- labstack/echo micro web framework
GoLang Resources
are all listed below.
GitHub - GuilhermeCaruso/anko: :crystal_ball: Simple application watcher
resource
~/github.com
resource
GitHub - jidicula/go-fuzz-action: GitHub Action for Go 1.18 fuzz testing
resource
~/github.com
resource
GitHub - tucnak/climax: Climax is an alternative CLI with the human face
resource
~/github.com
resource
GitHub - lawrencewoodman/roveralls: A Go recursive coverage testing tool
resource
~/github.com
resource
GitHub - nakagami/firebirdsql: Firebird RDBMS sql driver for Go (golang)
resource
~/github.com
resource
GitHub - liweiyi88/onedump: Effortlessly database dump with one command.
resource
~/github.com
resource
GitHub - beefsack/go-astar: Go implementation of the A* search algorithm
resource
~/github.com
resource
GitHub - lxn/walk: A Windows GUI toolkit for the Go Programming Language
resource
~/github.com
resource
GitHub - mongodb/mongo-go-driver: The Official Golang driver for MongoDB
resource
~/github.com
resource
GitHub - bykof/gostradamus: Gostradamus: Better DateTimes for Go ๐ฐ๏ธ
resource
~/github.com
resource
GitHub - mozillazg/go-unidecode: ASCII transliterations of Unicode text.
resource
~/github.com
resource
GitHub - bolknote/go-gd: Go bingings for GD (http://www.boutell.com/gd/)
resource
~/github.com
resource
GitHub - mosajjal/dnsmonster: Passive DNS Capture and Monitoring Toolkit
resource
~/github.com
resource
GitHub - haxpax/gosms: :mailbox_closed: Your own local SMS gateway in Go
resource
~/github.com
resource
GitHub - wajox/gobase: This is a simple skeleton for golang applications
resource
~/github.com
resource
GitHub - VividCortex/gohistogram: Streaming approximate histograms in Go
resource
~/github.com
resource
GitHub - malaschitz/randomForest: Random Forest implementation in golang
resource
~/github.com
resource
GitHub - google/gopacket: Provides packet processing capabilities for Go
resource
~/github.com
resource
GitHub - khezen/evoli: Genetic Algorithm and Particle Swarm Optimization
resource
~/github.com
resource
GitHub - didip/tollbooth: Simple middleware to rate-limit HTTP requests.
resource
~/github.com
resource
GitHub - mustafaakin/gongular: A different approach to Go web frameworks
resource
~/github.com
resource
GitHub - songgao/colorgo: Colorize (highlight) `go build` command output
resource
~/github.com
resource
Made with โค๏ธ
to provide different kinds of informations and resources.