Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thedanielforum/typed-form
Typed form parser for gin-gonic
https://github.com/thedanielforum/typed-form
gin gin-gonic go golang
Last synced: 25 days ago
JSON representation
Typed form parser for gin-gonic
- Host: GitHub
- URL: https://github.com/thedanielforum/typed-form
- Owner: thedanielforum
- License: mit
- Created: 2018-04-04T08:59:40.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-24T12:44:35.000Z (over 6 years ago)
- Last Synced: 2024-11-14T14:21:30.324Z (about 2 months ago)
- Topics: gin, gin-gonic, go, golang
- Language: Go
- Homepage:
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# typed-form
[![GoDoc](https://godoc.org/github.com/thedanielforum/typed-form?status.svg)](https://godoc.org/github.com/thedanielforum/typed-form) [![CircleCI](https://circleci.com/gh/thedanielforum/typed-form.svg?style=svg)](https://circleci.com/gh/thedanielforum/typed-form)
## How to use
```go
import form "github.com/thedanielforum/typed-form"// c is the gin context
form := form.Parse(c)
s := service.GetData(
form.GetParamInt64("id"),
form.GetString("name"),
)
if form.Errors() != nil {
err := form.Errors()[0]
c.JSON(http.StatusBadRequest, b.errorMsg(c, err.Error()))
return
}
```## Avalible Get's
```go
form := form.Parse(gin.Context)// Get post form data
form.GetString("key")
form.GetInt("key")
form.GetInt8("key")
form.GetInt16("key")
form.GetInt32("key")
form.GetInt64("key")// Get url param
form.GetParamString("key")
form.GetParamInt("key")
form.GetParamInt8("key")
form.GetParamInt16("key")
form.GetParamInt32("key")
form.GetParamInt64("key")// Get query param
form.GetQueryString("key")
form.GetQueryInt("key")
form.GetQueryInt8("key")
form.GetQueryInt16("key")
form.GetQueryInt32("key")
form.GetQueryInt64("key")
```