Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Closure example for go serve mux

To run:

 git clone https://github.com/guygrigsby/closure-example.git
 cd closure-example
 go run main.go

Endoint:

Method endpoint
GET /standard
GET /closure

Example:

curl localhost:8080/standard

or

curl localhost:8080/closure

Excersises for the reader:

Introduce another fixed value to the closure that could be important to the business logic of an http handler. Examples:

  • Pass is some config values.
    • A domain name
    • A list of users
  • Pass in a data structure to emulate a database, a map for example To create and use a map in GO:
func main() {
   m := make(map[string]string)
   m["food"] = "burrito"

   println(m["food"]) // prints "burrito"
}

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages