dekit

command module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2019 License: MIT Imports: 10 Imported by: 0

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",
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
examples
pizza
Code generated by dekit.
Code generated by dekit.

Jump to

Keyboard shortcuts

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