Coder Social home page Coder Social logo

fdk-go's People

Contributors

ant1eicher avatar denismakogon avatar gviedma avatar harryjsmith avatar hhexo avatar isaaclipszyc avatar kppk avatar metamemelord avatar michael-w-williams avatar puru-iiit avatar rdallman avatar riconnon avatar rishabhsri18 avatar roroco avatar skinowski avatar ssunny3141 avatar tcoupland avatar treeder avatar zootalures avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fdk-go's Issues

get the request query params

I am trying to get the request URL and parameters. But I am unable to get it. What is the method I can use to get the request params?

How to organize multiple functions under same repo?

What is a recommended way to manage multiple functions from code base perspective? My company want to move around 80 functionalities as OCI functions and I am wondering about the best way to organize these projects in a repository. Having 80 different git repos seems like an overkill. Do you have some best practices to organize multiple functions under same repo?

move readme examples into `_example.go`

then they get tested and compile and look good in godoc ;)

i may not actually be working on this, just assigning so it pops up to remind me when i'm scouring for work... feel free to take this

Unexpected panic during data processing with cloudevents

cat payload.json | fn call app route
{"error":{"message":"container exit code 2"}}
ERROR: error calling function: status 502

❯ fn logs g app last
panic: interface conversion: interface {} is map[string]interface {}, not string

goroutine 1 [running]:
func/vendor/github.com/fnproject/fdk-go/utils.DoCloudEventOnce(0x7f86bdad2fd0, 0x6ad9c8, 0x6ced40, 0xc420074d50, 0x6cc7c0, 0xc42000e010, 0x6cc7e0, 0xc42000e018, 0xc420104000, 0xc420074d80, ...)
    /go/src/func/vendor/github.com/fnproject/fdk-go/utils/cloudevent.go:88 +0x6b9
func/vendor/github.com/fnproject/fdk-go/utils.DoCloudEvent(0x7f86bdad2fd0, 0x6ad9c8, 0x6ced40, 0xc420074d50, 0x6cc7c0, 0xc42000e010, 0x6cc7e0, 0xc42000e018)
    /go/src/func/vendor/github.com/fnproject/fdk-go/utils/cloudevent.go:102 +0xd9
func/vendor/github.com/fnproject/fdk-go/utils.Do(0x7f86bdad2fd0, 0x6ad9c8, 0xc42001606a, 0xa, 0x6cc7c0, 0xc42000e010, 0x6cc7e0, 0xc42000e018)
    /go/src/func/vendor/github.com/fnproject/fdk-go/utils/utils.go:47 +0x1f6
func/vendor/github.com/fnproject/fdk-go.Handle(0x6ccc60, 0x6ad9c8)
    /go/src/func/vendor/github.com/fnproject/fdk-go/fdk.go:81 +0xce
main.main()
    /go/src/func/func.go:20 +0x39

Handling CORS headers inside a function

Hi there,

I'm trying to use fn and Golang to build an API that is callable from a browser. Within my function, I'd like to be able to handle CORS headers on the HTTP response, but I'm finding that fdk.setHeader() is prepending text to my header name, but it doesn't do it for the Content-Type examples provided.

So if I do this in my function:

	fdk.SetHeader(out, "Access-Control-Allow-Origin", "*")
	fdk.SetHeader(out, "Content-Type", "application/json")

I see this if you hit the function with curl -v

< Content-Type: application/json
< Fn-Http-H-Access-Control-Allow-Origin: *

So, I can set Content-Type directly but not add CORS headers to the response so that the browser will handle it correctly.

Any guidance?

Add Developer Content to the fdk-go Repo

This repo should have some developer information including:

  • How to obtain the Go FDK.
  • How to include the Go FDK in the build for runtime Go images.
  • How to include the Go FDK in program dependencies when building a custom runtime image using a Dockerfile.

502 on error

Currently the Go FDK doesn't handle errors in a user's function. As part of the FDK contract, the FDK should emit a 502 on a detectable error from the function. Not sure what the most idiomatic way of doing this from a user's perspective is. It could possibly involve the user setting a response status (500?) which the FDK then interprets as an error and gives a 502?

Update Go image on dockerhub

I am getting errors when working with some newer SDKs complaining that at least Go 1.12 is needed when trying to deploy my function. Can somebody do an update to the fnproject/go image on dockerhub to have a newer version included?

[cross-fdk] formalize context contract

At this moment most of the officially supported FDKs have a different understanding of what the context is. The bigger difference is in the context API. This issue is all about standardizing the context across FDKs that Fn officially supports.

fdk-go does not pass protocol info into context of handler function

in order to be able to find the http method which was used to invocate a function of format json, the context passed into a handler method in fdk-go should contain the protocol part of the JSON payload (https://github.com/fnproject/fn/blob/master/docs/developers/function-format.md).

Using the following code for a json-format function shows that this information is not passed into the handler:

func main() {
	fdk.Handle(fdk.HandlerFunc(testHandler))
}

func testHandler(ctx context.Context, in io.Reader, out io.Writer) {
	fnctx := fdk.Context(ctx)

	log.Println(fmt.Sprintf("%v", ctx))
	log.Println(fmt.Sprintf("%v", fnctx.Config))
	log.Println(fmt.Sprintf("%v", fnctx.Header))

}

Tag v1.0.0

It's really annoying that this project gets picked up and added:

require (
	github.com/fnproject/fdk-go v0.0.0-20190102214815-bd24a5aa63cf
)
$ go mod why github.com/fnproject/fdk-go
# github.com/fnproject/fdk-go
github.com/kounta/superfluid/v6/node_modules/serverless/lib/plugins/create/templates/fn-go/hello
github.com/fnproject/fdk-go

At least tag it so the go.sum file has a version.

Enhance error prompt while running go fn app locally

# fn init --runtime go hello
# go run func.go
panic: unknown format (fdk-go):

goroutine 1 [running]:
github.com/fnproject/fdk-go/utils.Do(0x14b3070, 0x128e178, 0x0, 0x0, 0x1380fe0, 0xc42000e010, 0x1381020, 0xc42000e018)
	/Users/jude/Programing/Go/Libraries/src/github.com/fnproject/fdk-go/utils/utils.go:51 +0x193
github.com/fnproject/fdk-go.Handle(0x1381a60, 0x128e178)
	/Users/jude/Programing/Go/Libraries/src/github.com/fnproject/fdk-go/fdk.go:81 +0xce
main.main()
	/Users/jude/Working/Oracle/Fn/apps/hello/func.go:14 +0x39
exit status 2

Fixing this issue is simple:

# export FN_FORMAT="default"
# echo '{"name": "Johnny"}' | ./func
{"message":"Hello Johnny"}

However for users who are totally new to the fn project they usually have no idea about what is going wrong there . They just wanna make sure their function works properly locally before building a fn app.

Shall we develop a patch in go FDK side for telling user what is going wrong there and how to fix it rather that a panic without any prompt ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.