Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Code generate http CRUD api and tests with ease.

License

Notifications You must be signed in to change notification settings

influx6/httpkit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Releases

No releases published

Packages

No packages published

Languages