rest-go alternatives and similar packages
Based on the "Utilities" category.
Alternatively, view rest-go alternatives based on common mentions on social networks and blogs.
-
xlsx
Library to simplify reading the XML format used by recent version of Microsoft Excel in Go programs. -
goreporter
A Golang tool that does static analysis, unit testing, code review and generate code quality report. -
go-funk
A modern Go utility library which provides helpers (map, find, contains, filter, chunk, reverse, ...) -
mc
Minio Client provides minimal tools to work with Amazon S3 compatible cloud storage and filesystems. -
mergo
A helper to merge structs and maps in Golang. Useful for configuration default values, avoiding messy if-statements. -
beaver
Beaver is a real-time messaging server. With beaver you can easily build scalable in-app notifications, realtime graphs, multiplayer games, chat applications, geotracking and more in web applications and mobile apps. -
httpcontrol
Package httpcontrol allows for HTTP transport level control around timeouts and retries.
Get performance insights in less than 4 minutes
Do you think we are missing an alternative of rest-go or a related project?
Popular Comparisons
README
Rest GO - Helpful library for Rest API
A package that provide many helpful methods for working with rest api.
And if u are tired of written, this:
func SomeHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Content-Type", "application/json")
product := &product{"Smart TV", 50.00}
bytes, err := json.Marshal(product)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
// this is super bad!
message := fmt.Sprintf(`{"message": "%s"}`, err.Error())
w.Write([]byte(message))
return
}
w.WriteHeader(http.StatusOk)
w.Write(bytes)
}
Get started:
- Install rest GO with one line of code
rest
package
The rest
package provides some helpful methods that allow you to write better rest api in GO.
- Allows for very readable code
See it in action:
package yours
import (
"github.com/edermanoel94/rest-go"
"net/http"
)
type product struct {
Name string `json:"name"`
Price float32 `json:"price"`
}
func SomeHandler(w http.ResponseWriter, r *http.Request) {
rest.Marshalled(w, &product{"Smart TV", 50.00}, http.StatusOK)
}
A payload send to your API and desarialize to a struct, to easy!
package yours
import (
"github.com/edermanoel94/rest-go"
"net/http"
)
type product struct {
Name string `json:"name"`
Price float32 `json:"price"`
}
// [POST] body: {"name": "eder", "price": 20.00}
func SomePostHandler(w http.ResponseWriter, r *http.Request) {
product := product{}
err := rest.GetBody(r.Body, &product)
if err != nil {
// do stuff with error
}
// Do stuff...
}
Working with mux
package to check if path variable exist.
package yours
import (
"github.com/edermanoel94/rest-go"
"github.com/gorilla/mux"
"net/http"
)
type product struct {
Name string `json:"name"`
Price float32 `json:"price"`
}
// [GET] url: /product/{id}
func SomePostHandler(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)
err := rest.CheckPathVariables(params, "id")
if err != nil {
// do stuff with error
}
}
TODO List
- [x] Working with custom errors
- [ ] Add Response for ALB and API Gateway
- [ ] Benchmarking (Memory, CPU)
- [ ] Working with CheckPathVariables and GetPathVariable in Standard library
- [ ] More tests
- [ ] Working with pagination
Installation
To install, use go get
using go modules:
go get github.com/edermanoel94/[email protected]
Example
To install and build:
cd examples
And use go modules for install packages:
go mod tidy
Then, to run:
go build
Contributing
Please feel free to submit issues, fork the repository and send pull requests!
License
This project is licensed under the terms of the MIT license.
*Note that all licence references and agreements mentioned in the rest-go README section above
are relevant to that project's source code only.