Binding middleware for tango
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
README.md
bind_test.go
binding.go
circle.yml
common_test.go
errorhandler_test.go
errors.go
errors_test.go
file_test.go
form.go
form_test.go
json.go
json_test.go
misc_test.go
multipart_test.go
validate.go
validate_test.go

README.md

binding CircleCI

Middlware binding provides request data binding and validation for Tango.

Installation

go get github.com/tango-contrib/binding

Example

import (
    "github.com/lunny/tango"
    "github.com/tango-contrib/binding"
)

type Action struct {
    binding.Binder
}

type MyStruct struct {
    Id int64
    Name string
}

func (a *Action) Get() string {
    var mystruct MyStruct
    errs := a.Bind(&mystruct)
    return fmt.Sprintf("%v, %v", mystruct, errs)
}

func main() {
    t := tango.Classic()
    t.Use(binding.Bind())
    t.Get("/", new(Action))
    t.Run()
}

Visit /?id=1&name=2 on your browser and you will find output

{1 sss}, []

Getting Help

Credits

This package is forked from macaron-contrib/binding with modifications.

License

This project is under Apache v2 License. See the LICENSE file for the full license text.