goa: github.com/goadesign/goa/goagen/gen_js Index | Files

package genjs

import "github.com/goadesign/goa/goagen/gen_js"

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/mzabriskie/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 Uses

func Generate() (files []string, err error)

Generate is the generator entry point called by the meta generator.

type Generator Uses

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 Uses

func NewGenerator(options ...Option) *Generator

NewGenerator returns an initialized instance of a JavaScript Client Generator

func (*Generator) Cleanup Uses

func (g *Generator) Cleanup()

Cleanup removes all the files generated by this generator during the last invokation of Generate.

func (*Generator) Generate Uses

func (g *Generator) Generate() (_ []string, err error)

Generate produces the skeleton main.

type Option Uses

type Option func(*Generator)

Option a generator option definition

func API Uses

func API(API *design.APIDefinition) Option

API The API definition

func Host Uses

func Host(host string) Option

Host addressed by JavaScript client

func NoExample Uses

func NoExample(noExample bool) Option

NoExample Do not generate an HTML example file

func OutDir Uses

func OutDir(outDir string) Option

OutDir Path to output directory

func Scheme Uses

func Scheme(scheme string) Option

Scheme Scheme used by JavaScript client

func Timeout Uses

func Timeout(timeout time.Duration) Option

Timeout Timeout used by JavaScript client when making requests

Package genjs imports 12 packages (graph) and is imported by 6 packages. Updated 2017-08-07. Refresh now. Tools for package owners.