Popularity
2.0
Stable
Activity
3.7
-
13
3
3
Programming language: Go
License: MIT License
Tags:
Utilities
Latest version: v1.0.1
jsend alternatives and similar packages
Based on the "Utilities" category.
Alternatively, view jsend 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
Scout APM uses tracing logic that ties bottlenecks to source code so you know the exact line of code causing performance issues and can get back to building a great product faster.
Sponsored
scoutapm.com
Do you think we are missing an alternative of jsend or a related project?
Popular Comparisons
README
JSend's implementation writen in Go(golang)
This package is an implementation of JSend specification written in Go(golang).
Installation
go get clevergo.tech/jsend
Usage
Usage is pretty simple.
// success response
jsend.Success(w, data)
// fail response
jsend.Fail(w, data)
// error response
jsend.Error(w, message)
// error response with extra code
jsend.ErrorCode(w, message, code)
// error response with extra code and data
jsend.ErrorCodeData(w, message, code, data)
It can also be integrated with web framework, such as Gin, Echo, CleverGo:
// success response
ctx.JSON(http.StatusOK, jsend.New(data))
// fail response
ctx.JSON(http.StatusOK, jsend.NewFail(data))
// error response
ctx.JSON(http.StatusOK, jsend.NewError(message, code, data))
Checkout example for details.
Error Handling
It is application responsibility to handle error.
Status Code
By default status code http.StatusOK
was used implicitly,
it can also be specified by the last parameter if necessary.
jsend.Success(w, data, http.StatusOK)
jsend.Fail(w, data, http.StatusForbidden)
jsend.Error(w, message, http.StatusInternalServerError)