binding

package
v0.2.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2025 License: MIT Imports: 9 Imported by: 0

README

HTTP Binding

QueryBiding

Example:

package main

import (
	"fmt"
	"net/http"
	"net/url"

	"github.com/QisFj/godry/http/binding"
)

func main() {
	req := &http.Request{URL: &url.URL{RawQuery: "a=1&b.c=2"}}
	var obj struct {
		A int
		B struct {
			C int
		}
	}
	err := binding.QueryBinding{}.Bind(req, &obj)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Printf("Resp: %#v\n", obj)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Binding

type Binding interface {
	Bind(*http.Request, interface{}) error
}

type Func

type Func func(*http.Request, interface{}) error

func (Func) Bind

func (f Func) Bind(r *http.Request, v interface{}) error

type QueryBinding

type QueryBinding struct {
	Validate ValidateFunc
}

func (QueryBinding) Bind

func (b QueryBinding) Bind(r *http.Request, v interface{}) (err error)

type ValidateFunc

type ValidateFunc func(v interface{}) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL