-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from LucienShui/doc/swagger
add swagger comment, add swagger in ci, remove aliyun in docker build…
- Loading branch information
Showing
10 changed files
with
183 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,28 @@ | ||
package common | ||
|
||
import "errors" | ||
import ( | ||
"errors" | ||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
var ( | ||
ErrNoRouterFounded = errors.New("no router founded") | ||
) | ||
|
||
type ErrorResponse struct { | ||
*Response | ||
Message string `json:"message" example:"ok"` | ||
} | ||
|
||
func Error(context *gin.Context, status int, err error) { | ||
httpStatusCode := 0 | ||
|
||
if status < 1000 { | ||
httpStatusCode = status | ||
} else { | ||
httpStatusCode = status / 100 | ||
} | ||
|
||
response := ErrorResponse{&Response{Status: status}, err.Error()} | ||
context.JSON(httpStatusCode, response) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.