Skip to content

Commit

Permalink
Merge branch 'release/0.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Elena Grahovac committed May 22, 2017
2 parents 16ad3c0 + d5a473f commit d76091f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
step-by-step
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@ An example of a service, which "evolves" step by step.

It might be helpful to set up git pre-commit hooks before writing the code.
For example, you can use [pre-commit by Yelp](http://pre-commit.com) to manage this kind of hooks.

See `.pre-commit-config.yaml`.

## Step 02. Add the simplest web-server

The simplest way to make a web-server: register a handler function and listen on some TCP network address:

http.HandleFunc("/", home)
http.ListenAndServe(":8000", nil)
11 changes: 11 additions & 0 deletions handlers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

import (
"fmt"
"net/http"
)

// home returns the path of current request
func home(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Processing URL %s...", r.URL.Path)
}
12 changes: 12 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package main

import (
"net/http"
)

// Run server: go build && step-by-step
// Try requests: curl http://127.0.0.1:8000/test
func main() {
http.HandleFunc("/", home)
http.ListenAndServe(":8000", nil)
}

0 comments on commit d76091f

Please sign in to comment.