Skip to content

Commit e08d592

Browse files
committed
Adding webapp files.
1 parent 3507b9c commit e08d592

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Building on top of Ubuntu 14.04. The best distro around.
2+
FROM ubuntu:14.04
3+
4+
ADD ./go-ecs-ecr /opt
5+
EXPOSE 8080
6+
7+
ENTRYPOINT ["/opt/go-ecs-ecr"]

main.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package main
2+
3+
import(
4+
"fmt"
5+
"net/http"
6+
)
7+
8+
func mainHandler() http.HandlerFunc{
9+
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request){
10+
fmt.Fprintf(w, "Hello World!")
11+
})
12+
}
13+
14+
func main(){
15+
http.HandleFunc("/", mainHandler())
16+
http.ListenAndServe(":8080", nil)
17+
}

main_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package main
2+
3+
import(
4+
"net/http"
5+
"net/http/httptest"
6+
"testing"
7+
)
8+
9+
func TestHomepage(t *testing.T){
10+
mainHandle := mainHandler()
11+
http.HandleFunc("/", mainHandle)
12+
req, _ := http.NewRequest("GET", "", nil)
13+
w := httptest.NewRecorder()
14+
mainHandle.ServeHTTP(w, req)
15+
16+
if w.Code != http.StatusOK{
17+
t.Errorf("The homepage returned HTTP %v instead of HTTP %v as expected.", w.Code, http.StatusOK)
18+
}
19+
}

0 commit comments

Comments
 (0)