genjs

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

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

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

Types

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 added in v1.2.0

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 added in v1.2.0

type Option func(*Generator)

Option a generator option definition

func API added in v1.2.0

func API(API *design.APIDefinition) Option

API The API definition

func Host added in v1.2.0

func Host(host string) Option

Host addressed by JavaScript client

func NoExample added in v1.2.0

func NoExample(noExample bool) Option

NoExample Do not generate an HTML example file

func OutDir added in v1.2.0

func OutDir(outDir string) Option

OutDir Path to output directory

func Scheme added in v1.2.0

func Scheme(scheme string) Option

Scheme Scheme used by JavaScript client

func Timeout added in v1.2.0

func Timeout(timeout time.Duration) Option

Timeout Timeout used by JavaScript client when making requests

Jump to

Keyboard shortcuts

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