Giter VIP home page Giter VIP logo

Comments (4)

ssttevee avatar ssttevee commented on May 27, 2024 1

Yes, you should be able to add a framework layer as long as it can take the http.Handler interface.

Using that specific library, it would look something like this:

func main() {
	flag.Parse()

	goji.Handle(nodego.HTTPTrigger, func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintln(w, "Hello, I'm native Go!")
	})

	DefaultMux.Compile()

	http.Handle("/", DefaultMux)

	nodego.TakeOver()
}

However, I don't see much of a purpose since there is only one url you can handle on GCF (i.e. /execute).

from cloud-functions-go.

prep avatar prep commented on May 27, 2024

Are you sure about that latter part of your comment, @ssttevee? If I deploy a Google Cloud Function written in Go and call /foo/bar/zoink on the base URL, it gets received as /execute/foo/bar/zoink in my http.Handler.

To make that work with my custom router I just need to strip away /execute from r.URL.Path and r.RequestURI.

from cloud-functions-go.

iangudger avatar iangudger commented on May 27, 2024

@prep, are you asking how to strip the path?

from cloud-functions-go.

prep avatar prep commented on May 27, 2024

@iangudger, I was saying that the latter part of @ssttevee's comment seems to suggest that a function is only been given a singular URL path, namely /execute, and therefore an alternative HTTP router doesn't make much sense.

In my experience, you can serve many paths from your function with the only caveat that all URL paths have the /execute prefix to them which I suggested can be stripped away before they hit your router (by way of stripping them in ServeHTTP(), for example).

from cloud-functions-go.

Related Issues (20)

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.