Binding middleware for tango
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lunny Xiao f7676e2641
add drone.yml
6 months ago
.drone.yml add drone.yml 6 months ago
LICENSE init 4 years ago
README.md add drone.yml 6 months ago
bind_test.go init 4 years ago
binding.go update github.com/lunny/tango to gitea.com/lunny/tango 6 months ago
circle.yml update CI config 2 years ago
common_test.go update github.com/lunny/tango to gitea.com/lunny/tango 6 months ago
errorhandler_test.go init 4 years ago
errors.go add errors map 4 years ago
errors_test.go init 4 years ago
file_test.go update github.com/lunny/tango to gitea.com/lunny/tango 6 months ago
form.go init 4 years ago
form_test.go update github.com/lunny/tango to gitea.com/lunny/tango 6 months ago
go.mod add drone.yml 6 months ago
go.sum add drone.yml 6 months ago
json.go init 4 years ago
json_test.go update github.com/lunny/tango to gitea.com/lunny/tango 6 months ago
misc_test.go update github.com/lunny/tango to gitea.com/lunny/tango 6 months ago
multipart_test.go update github.com/lunny/tango to gitea.com/lunny/tango 6 months ago
validate.go init 4 years ago
validate_test.go update github.com/lunny/tango to gitea.com/lunny/tango 6 months ago

README.md

binding Build Status

Middlware binding provides request data binding and validation for Tango.

Installation

go get gitea.com/tango/binding

Example

import (
    "gitea.com/lunny/tango"
    "gitea.com/tango/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.