当前位置: 首页>>代码示例>>Golang>>正文


Golang Function.Handler方法代码示例

本文整理汇总了Golang中github.com/apex/apex/function.Function.Handler方法的典型用法代码示例。如果您正苦于以下问题:Golang Function.Handler方法的具体用法?Golang Function.Handler怎么用?Golang Function.Handler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/apex/apex/function.Function的用法示例。


在下文中一共展示了Function.Handler方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Build

// Build injects a script for loading the environment.
func (p *Plugin) Build(fn *function.Function, zip *archive.Zip) error {
	if fn.Runtime != RuntimeCanonical || len(fn.Environment) == 0 {
		return nil
	}

	if len(strings.Split(fn.Handler, ".")) < 2 {
		return errors.New("lambda requires handler function name to be of the format 'filename.function_name'")
	}

	fn.Log.Debug("injecting prelude")

	var buf bytes.Buffer
	file := strings.Split(fn.Handler, ".")[0]
	method := strings.Split(fn.Handler, ".")[1]

	err := prelude.Execute(&buf, struct {
		EnvFile      string
		HandleFile   string
		HandleMethod string
	}{
		EnvFile:      env.FileName,
		HandleFile:   file,
		HandleMethod: method,
	})

	if err != nil {
		return err
	}

	fn.Handler = "_apex_main." + method

	return zip.AddBytes("_apex_main.py", buf.Bytes())
}
开发者ID:DavidTPate,项目名称:apex,代码行数:34,代码来源:python.go

示例2: Build

// Build injects a script for loading the environment.
func (p *Plugin) Build(fn *function.Function, zip *archive.Archive) error {
	if len(fn.Environment) == 0 {
		return nil
	}

	fn.Log.Debug("injecting prelude")

	var buf bytes.Buffer
	file := strings.Split(fn.Handler, ".")[0]
	method := strings.Split(fn.Handler, ".")[1]

	err := prelude.Execute(&buf, struct {
		EnvFile      string
		HandleFile   string
		HandleMethod string
	}{
		EnvFile:      ".env.json",
		HandleFile:   file,
		HandleMethod: method,
	})

	if err != nil {
		return err
	}

	fn.Handler = "_apex_index.handle"

	return zip.AddBytes("_apex_index.js", buf.Bytes())
}
开发者ID:kujohn,项目名称:apex,代码行数:30,代码来源:nodejs.go

示例3: Build

// Build injects a script for loading the environment.
func (p *Plugin) Build(fn *function.Function, zip *archive.Archive) error {
	if fn.Runtime != RuntimeCanonical || len(fn.Environment) == 0 {
		return nil
	}

	fn.Log.Debug("injecting prelude")

	var buf bytes.Buffer
	file := strings.Split(fn.Handler, ".")[0]
	method := strings.Split(fn.Handler, ".")[1]

	err := prelude.Execute(&buf, struct {
		EnvFile      string
		HandleFile   string
		HandleMethod string
	}{
		EnvFile:      env.FileName,
		HandleFile:   file,
		HandleMethod: method,
	})

	if err != nil {
		return err
	}

	fn.Handler = "_apex_main.handle"

	return zip.AddBytesMTime("_apex_main.py", buf.Bytes(), time.Unix(0, 0))
}
开发者ID:elizar,项目名称:apex,代码行数:30,代码来源:python.go

示例4: Open

// Open adds nodejs defaults.
func (p *Plugin) Open(fn *function.Function) error {
	if fn.Runtime != "nodejs" {
		return nil
	}

	if fn.Handler == "" {
		fn.Handler = "index.handle"
	}

	return nil
}
开发者ID:kujohn,项目名称:apex,代码行数:12,代码来源:nodejs.go

示例5: Run

// Run specifies nodejs defaults.
func (p *Plugin) Run(hook function.Hook, fn *function.Function) error {
	if hook != function.OpenHook || fn.Runtime != "nodejs" {
		return nil
	}

	if fn.Handler == "" {
		fn.Handler = "index.handle"
	}

	return nil
}
开发者ID:pilwon,项目名称:apex,代码行数:12,代码来源:nodejs.go

示例6: Open

// Open adds nodejs defaults.
func (p *Plugin) Open(fn *function.Function) error {
	if !p.runtimeSupported(fn) {
		return nil
	}

	if fn.Handler == "" {
		fn.Handler = "index.handle"
	}

	return nil
}
开发者ID:DavidTPate,项目名称:apex,代码行数:12,代码来源:nodejs.go

示例7: Open

// Open adds python defaults.
func (p *Plugin) Open(fn *function.Function) error {
	if fn.Runtime != "python" {
		return nil
	}

	fn.Runtime = "python2.7"

	if fn.Handler == "" {
		fn.Handler = "main.handle"
	}

	return nil
}
开发者ID:kujohn,项目名称:apex,代码行数:14,代码来源:python.go

示例8: Open

// Open adds python defaults.
func (p *Plugin) Open(fn *function.Function) error {
	if fn.Runtime != Runtime {
		return nil
	}

	fn.Runtime = RuntimeCanonical

	if fn.Handler == "" {
		fn.Handler = "main.handle"
	}

	return nil
}
开发者ID:elizar,项目名称:apex,代码行数:14,代码来源:python.go

示例9: Run

// Run specifies python defaults.
func (p *Plugin) Run(hook function.Hook, fn *function.Function) error {
	if hook != function.OpenHook || fn.Runtime != "python" {
		return nil
	}

	fn.Runtime = "python2.7"

	if fn.Handler == "" {
		fn.Handler = "main.handle"
	}

	return nil
}
开发者ID:pilwon,项目名称:apex,代码行数:14,代码来源:python.go

示例10: Open

// Open adds java defaults.
func (p *Plugin) Open(fn *function.Function) error {
	if fn.Runtime != Runtime {
		return nil
	}

	fn.Runtime = RuntimeCanonical

	if fn.Handler == "" {
		fn.Handler = "lambda.Main::handler"
	}

	fn.Hooks.Clean = "mvn clean"

	return nil
}
开发者ID:elizar,项目名称:apex,代码行数:16,代码来源:java.go

示例11: Open

// Open adds java defaults. No clean operation is implemented, as it is
// assumed that the build tool generating the fat JAR will handle that workflow
// on its own.
func (p *Plugin) Open(fn *function.Function) error {
	if fn.Runtime != Runtime {
		return nil
	}

	if fn.Handler == "" {
		fn.Handler = "lambda.Main::handler"
	}

	if len(fn.IgnoreFile) == 0 {
		// Since we're deploying a fat jar, we don't need anything else.
		fn.IgnoreFile = []byte(`
*
!**/apex.jar
`)
	}

	return nil
}
开发者ID:DavidTPate,项目名称:apex,代码行数:22,代码来源:java.go


注:本文中的github.com/apex/apex/function.Function.Handler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。