Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openfaas-faas
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Team Jaz CS 598 CCC Final Project
openfaas-faas
Commits
734c8a3d
Commit
734c8a3d
authored
8 years ago
by
Alex
Browse files
Options
Downloads
Patches
Plain Diff
gateway 0.01
parent
606a50e1
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
gateway/.gitignore
+1
-0
1 addition, 0 deletions
gateway/.gitignore
gateway/Dockerfile
+15
-0
15 additions, 0 deletions
gateway/Dockerfile
gateway/server.go
+40
-0
40 additions, 0 deletions
gateway/server.go
with
56 additions
and
0 deletions
gateway/.gitignore
0 → 100644
+
1
−
0
View file @
734c8a3d
gateway
This diff is collapsed.
Click to expand it.
gateway/Dockerfile
0 → 100644
+
15
−
0
View file @
734c8a3d
from
golang:1.7.3
RUN
go get
-d
github.com/docker/docker/api/types
\
&&
go get
-d
github.com/docker/docker/api/types/filters
\
&&
go get
-d
github.com/docker/docker/api/types/swarm
\
&&
go get
-d
github.com/docker/docker/client
WORKDIR
/go/src/app/
RUN
go get github.com/gorilla/mux
COPY
server.go .
RUN
go build
EXPOSE
8080
CMD
["./app"]
This diff is collapsed.
Click to expand it.
gateway/server.go
0 → 100644
+
40
−
0
View file @
734c8a3d
package
main
import
(
"bytes"
"log"
"net/http"
"io/ioutil"
"strconv"
"github.com/gorilla/mux"
)
func
proxy
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
if
r
.
Method
==
"POST"
{
log
.
Println
(
r
.
Header
)
header
:=
r
.
Header
[
"X-Function"
]
log
.
Println
(
header
)
if
header
[
0
]
==
"catservice"
{
// client := http.Client{Timeout: time.Second * 2}
requestBody
,
_
:=
ioutil
.
ReadAll
(
r
.
Body
)
buf
:=
bytes
.
NewBuffer
(
requestBody
)
response
,
err
:=
http
.
Post
(
"http://"
+
header
[
0
]
+
":"
+
strconv
.
Itoa
(
8080
)
+
"/"
,
"text/plain"
,
buf
)
if
err
!=
nil
{
log
.
Fatalln
(
err
)
}
responseBody
,
_
:=
ioutil
.
ReadAll
(
response
.
Body
)
w
.
Write
(
responseBody
)
}
}
}
func
main
()
{
r
:=
mux
.
NewRouter
()
r
.
HandleFunc
(
"/"
,
proxy
)
log
.
Fatal
(
http
.
ListenAndServe
(
":8080"
,
r
))
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment