This repository has been archived by the owner on Jun 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
82 changed files
with
1,265 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- repo: git://github.com/dnephin/pre-commit-golang | ||
sha: 471a7c123ea7a3b776ff018edf00066947873a94 | ||
hooks: | ||
- id: go-fmt | ||
- id: go-vet | ||
- id: go-lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
app | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- repo: git://github.com/dnephin/pre-commit-golang | ||
sha: 471a7c123ea7a3b776ff018edf00066947873a94 | ||
hooks: | ||
- id: go-fmt | ||
- id: go-vet | ||
- id: go-lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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...\n", r.URL.Path) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package main | ||
|
||
import ( | ||
"net/http" | ||
) | ||
|
||
// Run server: go build -o app && ./app | ||
// Try requests: curl http://127.0.0.1:8000/any | ||
func main() { | ||
http.HandleFunc("/", home) | ||
http.ListenAndServe(":8000", nil) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
app | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- repo: git://github.com/dnephin/pre-commit-golang | ||
sha: 471a7c123ea7a3b776ff018edf00066947873a94 | ||
hooks: | ||
- id: go-fmt | ||
- id: go-vet | ||
- id: go-lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/julienschmidt/httprouter" | ||
) | ||
|
||
// home returns the path of current request | ||
func home(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { | ||
fmt.Fprintf(w, "Processing URL %s...\n", r.URL.Path) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package main | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/julienschmidt/httprouter" | ||
) | ||
|
||
// Run server: go build -o app && ./app | ||
// Try requests: curl http://127.0.0.1:8000/ | ||
func main() { | ||
router := httprouter.New() | ||
router.GET("/", home) | ||
|
||
http.ListenAndServe(":8000", router) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
app | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- repo: git://github.com/dnephin/pre-commit-golang | ||
sha: 471a7c123ea7a3b776ff018edf00066947873a94 | ||
hooks: | ||
- id: go-fmt | ||
- id: go-vet | ||
- id: go-lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/julienschmidt/httprouter" | ||
) | ||
|
||
// home returns the path of current request | ||
func home(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { | ||
fmt.Fprintf(w, "Processing URL %s...\n", r.URL.Path) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package main | ||
|
||
import ( | ||
"io/ioutil" | ||
"net/http" | ||
"net/http/httptest" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/julienschmidt/httprouter" | ||
) | ||
|
||
// TestHandler is the simplest test: check home (/) URL | ||
// go test | ||
func TestHandler(t *testing.T) { | ||
router := httprouter.New() | ||
router.GET("/", home) | ||
|
||
ts := httptest.NewServer(router) | ||
defer ts.Close() | ||
|
||
res, err := http.Get(ts.URL + "/") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
greeting, err := ioutil.ReadAll(res.Body) | ||
res.Body.Close() | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
expectedGreeting := "Processing URL /..." | ||
testingGreeting := strings.Trim(string(greeting), " \n") | ||
if testingGreeting != expectedGreeting { | ||
t.Fatalf( | ||
"Wrong greeting '%s', expected '%s'", | ||
testingGreeting, expectedGreeting, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package main | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/julienschmidt/httprouter" | ||
) | ||
|
||
// Run server: go build -o app && ./app | ||
// Try requests: curl http://127.0.0.1:8000/ | ||
func main() { | ||
router := httprouter.New() | ||
router.GET("/", home) | ||
|
||
http.ListenAndServe(":8000", router) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
app | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- repo: git://github.com/dnephin/pre-commit-golang | ||
sha: 471a7c123ea7a3b776ff018edf00066947873a94 | ||
hooks: | ||
- id: go-fmt | ||
- id: go-vet | ||
- id: go-lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/julienschmidt/httprouter" | ||
) | ||
|
||
// home returns the path of current request | ||
func home(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { | ||
log.Info("Request received.") | ||
fmt.Fprintf(w, "Processing URL %s...\n", r.URL.Path) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package main | ||
|
||
import ( | ||
"io/ioutil" | ||
"net/http" | ||
"net/http/httptest" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/julienschmidt/httprouter" | ||
) | ||
|
||
// TestHandler is the simplest test: check home (/) URL | ||
// go test | ||
func TestHandler(t *testing.T) { | ||
router := httprouter.New() | ||
router.GET("/", home) | ||
|
||
ts := httptest.NewServer(router) | ||
defer ts.Close() | ||
|
||
res, err := http.Get(ts.URL + "/") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
greeting, err := ioutil.ReadAll(res.Body) | ||
res.Body.Close() | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
expectedGreeting := "Processing URL /..." | ||
testingGreeting := strings.Trim(string(greeting), " \n") | ||
if testingGreeting != expectedGreeting { | ||
t.Fatalf( | ||
"Wrong greeting '%s', expected '%s'", | ||
testingGreeting, expectedGreeting, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package main | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/Sirupsen/logrus" | ||
"github.com/julienschmidt/httprouter" | ||
) | ||
|
||
var log = logrus.New() | ||
|
||
// Run server: go build -o app && ./app | ||
// Try requests: curl http://127.0.0.1:8000/ | ||
func main() { | ||
log.Info("Initialize service...") | ||
|
||
router := httprouter.New() | ||
router.GET("/", home) | ||
|
||
log.Info("Service is ready to listen and serve.") | ||
http.ListenAndServe(":8000", router) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
app | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- repo: git://github.com/dnephin/pre-commit-golang | ||
sha: 471a7c123ea7a3b776ff018edf00066947873a94 | ||
hooks: | ||
- id: go-fmt | ||
- id: go-vet | ||
- id: go-lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/julienschmidt/httprouter" | ||
) | ||
|
||
// home returns the path of current request | ||
func home(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { | ||
log.Info("Request received.") | ||
fmt.Fprintf(w, "Processing URL %s...\n", r.URL.Path) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package main | ||
|
||
import ( | ||
"io/ioutil" | ||
"net/http" | ||
"net/http/httptest" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/julienschmidt/httprouter" | ||
) | ||
|
||
// TestHandler is the simplest test: check home (/) URL | ||
// go test | ||
func TestHandler(t *testing.T) { | ||
router := httprouter.New() | ||
router.GET("/", home) | ||
|
||
ts := httptest.NewServer(router) | ||
defer ts.Close() | ||
|
||
res, err := http.Get(ts.URL + "/") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
greeting, err := ioutil.ReadAll(res.Body) | ||
res.Body.Close() | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
expectedGreeting := "Processing URL /..." | ||
testingGreeting := strings.Trim(string(greeting), " \n") | ||
if testingGreeting != expectedGreeting { | ||
t.Fatalf( | ||
"Wrong greeting '%s', expected '%s'", | ||
testingGreeting, expectedGreeting, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package main | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/Sirupsen/logrus" | ||
"github.com/julienschmidt/httprouter" | ||
) | ||
|
||
var log = logrus.New() | ||
|
||
// Prepare vendoring config: glide init; glide install | ||
|
||
// Run server: go build -o app && ./app | ||
// Try requests: curl http://127.0.0.1:8000/ | ||
func main() { | ||
log.Info("Initialize service...") | ||
|
||
router := httprouter.New() | ||
router.GET("/", home) | ||
|
||
log.Info("Service is ready to listen and serve.") | ||
http.ListenAndServe(":8000", router) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
app | ||
vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- repo: git://github.com/dnephin/pre-commit-golang | ||
sha: 471a7c123ea7a3b776ff018edf00066947873a94 | ||
hooks: | ||
- id: go-fmt | ||
- id: go-vet | ||
- id: go-lint |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package: github.com/rumyantseva/production-ready-microservices/practice/07-config | ||
import: | ||
- package: github.com/Sirupsen/logrus | ||
version: ^1.0.2 | ||
- package: github.com/julienschmidt/httprouter | ||
version: ^1.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/julienschmidt/httprouter" | ||
) | ||
|
||
// home returns the path of current request | ||
func home(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { | ||
log.Info("Request received.") | ||
fmt.Fprintf(w, "Processing URL %s...\n", r.URL.Path) | ||
} |
Oops, something went wrong.