Categorygithub.com/go-gad/dekit
modulepackage
0.1.0
Repository: https://github.com/go-gad/dekit.git
Documentation: pkg.go.dev

# README

dekit

Toolchain to generate decoder based on request's struct

Install

go get -u github.com/go-gad/dekit

Usage

❯ dekit -h
Usage:
    dekit [options...] <import_path> <parameter_names>

Example:
        dekit -destination=./decoders_dekit.go github.com/go-gad/dekit/examples/pizza CreateOrderReq

  <import_path>
        describes the complete package path where the parameter is located.
  <parameter_names>
        indicates the parameter names that are separated by comma.

Options:
  -build_flags string
        Additional flags for go build.
  -destination string
        Output file; defaults to stdout.

Purpose

type UpdateAuthorReq struct {
    ID int64 `path:"id"`
    Name string `query_string:"name"`
    Body string `json:"body"`
    Slug string `header:"X-Slug"`
}

Request:

curl -X PATCH -H "X-Slug: ivanov" http://site.com/authors/123?name=Alex -d '{"body":"a good person"}'

dekitgen will generate a decoder which convert *http.Request to struct with filled struct:

...
return UpdateAuthorReq {
    ID: 123,
    Name: "Alex",
    Body: "a good person",
    Slug: "ivanov",
}

# Packages

No description provided by the author
No description provided by the author

# Functions

No description provided by the author