Skip to content
forked from anexia/go-e5e

Support library to help Go developers build Anexia e5e functions

License

Notifications You must be signed in to change notification settings

anx-mschaefer/go-e5e

 
 

Repository files navigation

go-e5e

PkgGoDev Build Status codecov Go Report Card

go-e5e is a support library to help Go developers build Anexia e5e functions.

Install

With a correctly configured Go toolchain:

go get -u go.anx.io/e5e

Getting started

package main

import (
	"runtime"
	
	"go.anx.io/e5e"
)

type SumEventData struct {
	A int `json:"a"`
	B int `json:"b"`
}

type SumEvent struct {
	e5e.Event
	Data SumEventData `json:"data,omitempty"`
}

// Using a custom `e5e.Context` class is optional and only needed to access the `Data` attribute on the
// context. This attribute may be used to get the return value of an authorizer function, for example. If access
// to the `Data` attribute is not needed, the `e5e.Context` type can be used on the entrypoint directly.

type SumContextData struct {
	AuthKey string `json:"auth_key"`
}

type SumContext struct {
	e5e.Context
	Data SumContextData `json:"data,omitempty"`
}

type entrypoints struct{}

func (f *entrypoints) MyEntrypoint(event SumEvent, context SumContext) (e5e.Result, error) {
	return e5e.Result{
		Status: 200,
		ResponseHeaders: map[string]string{
			"x-custom-response-header": "This is a custom response header",
		},
		Data: map[string]interface{}{
			"sum": event.Data.A + event.Data.B,
			"version": runtime.Version(),
		},
	}, nil
}

func main() {
	e5e.Start(&entrypoints{})
}

List of developers

About

Support library to help Go developers build Anexia e5e functions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%