github.com/goadesign/goa/goagen/gen_js
genjs
import "github.com/goadesign/goa/goagen/gen_js"
Overview
Package genjs provides a goa generator for a javascript client module. The module exposes functions for calling the API actions. It relies on the axios (https://github.com/axios/axios) javascript library to perform the actual HTTP requests.
The generator also produces an example controller and index HTML that shows how to use the module. The controller simply serves all the files under the “js” directory so that loading “/js” in a browser triggers the example code.
Index
Package files
doc.go generator.go options.go
func Generate
func Generate() (files []string, err error)
Generate is the generator entry point called by the meta generator.
type Generator
type Generator struct {
API *design.APIDefinition // The API definition
OutDir string // Destination directory
Timeout time.Duration // Timeout used by JavaScript client when making requests
Scheme string // Scheme used by JavaScript client
Host string // Host addressed by JavaScript client
NoExample bool // Do not generate an HTML example file
// contains filtered or unexported fields
}
Generator is the application code generator.
func NewGenerator
func NewGenerator(options ...Option) *Generator
NewGenerator returns an initialized instance of a JavaScript Client Generator
func (*Generator) Cleanup
func (g *Generator) Cleanup()
Cleanup removes all the files generated by this generator during the last invokation of Generate.
func (*Generator) Generate
func (g *Generator) Generate() (_ []string, err error)
Generate produces the skeleton main.
type Option
type Option func(*Generator)
Option a generator option definition
func API
func API(API *design.APIDefinition) Option
API The API definition
func Host
func Host(host string) Option
Host addressed by JavaScript client
func NoExample
func NoExample(noExample bool) Option
NoExample Do not generate an HTML example file
func OutDir
func OutDir(outDir string) Option
OutDir Path to output directory
func Scheme
func Scheme(scheme string) Option
Scheme Scheme used by JavaScript client
func Timeout
func Timeout(timeout time.Duration) Option
Timeout Timeout used by JavaScript client when making requests
Generated by godoc2md