httpkit

command module
v0.0.0-...-203dbfa Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2018 License: MIT Imports: 7 Imported by: 0

README

HTTPKit

Go Report Card

HTTPKit implements a code generator which automatically generates go packages for a http CRUD implementations for annotated structs.

Install

go get -u github.com/gokit/httpkit

Examples

See Examples for demonstrations of httpkit code generation.

Usage

Running the following commands instantly generates all necessary files and packages for giving code gen.

> httpkit generate

How It works

You annotate any giving struct with @httpapi which marks giving struct has a target for code generation.

It also respects attributes like New and Update on the @httpapi annotation, these two provide information to the generator for:

  1. What struct to be used as representing a new data for struct type.
  2. What struct contain information for representing the update data for struct type.

Sample below:

// User is a type defining the given user related fields for a given.
//@httpapi(New => NewUser, Update => UpdatedUser)
type User struct {
	Username      string    `json:"username"`
	PublicID      string    `json:"public_id"`
	PrivateID     string    `json:"private_id"`
	Hash          string    `json:"hash"`
	TwoFactorAuth bool      `json:"two_factor_auth"`
	Created       time.Time `json:"created_at"`
	Updated       time.Time `json:"updated_at"`
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
userapi
Package userapi provides a auto-generated package which contains a http restful CRUD API for the specific User struct in package users.
Package userapi provides a auto-generated package which contains a http restful CRUD API for the specific User struct in package users.

Jump to

Keyboard shortcuts

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