Popularity
4.1
Stable
Activity
0.0
Stable
101
5
4
Programming language: Go
License: Apache License 2.0
Latest version: v1.2.2
gores alternatives and similar packages
Based on the "Libraries for creating HTTP middlewares" category.
Alternatively, view gores alternatives based on common mentions on social networks and blogs.
-
render
Go package for easily rendering JSON, XML, binary data, and HTML templates responses.
Clean code begins in your IDE with SonarLint
Up your coding game and discover issues early. SonarLint is a free plugin that helps you find & fix bugs and security issues from the moment you start writing code. Install from your favorite IDE marketplace today.
Promo
www.sonarlint.org
Do you think we are missing an alternative of gores or a related project?
Popular Comparisons
README
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
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