Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ACS
Public
Cloud
MAS
clonemap
Commits
5f6b473b
Commit
5f6b473b
authored
Jun 30, 2020
by
Stefan Dähling
Browse files
frontend ams handler
parent
c6101605
Pipeline
#301455
failed with stages
in 2 minutes and 40 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
pkg/frontend/handler.go
View file @
5f6b473b
...
...
@@ -49,6 +49,7 @@ import (
"net/http"
"strings"
amsclient
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/ams/client"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/common/httpreply"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/schemas"
)
...
...
@@ -86,18 +87,41 @@ func (fe *Frontend) handleAPI(w http.ResponseWriter, r *http.Request) {
}
// handleAMS handles requests to /api/ams/...
func
(
fe
*
Frontend
)
handleAMS
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
respath
[]
string
)
(
cmapErr
,
httpErr
error
)
{
func
(
fe
*
Frontend
)
handleAMS
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
respath
[]
string
)
(
resvalid
bool
,
cmapErr
,
httpErr
error
)
{
resvalid
=
false
switch
len
(
respath
)
{
case
3
:
var
temp
schemas
.
MASInfo
httpErr
=
httpreply
.
Resource
(
w
,
temp
,
cmapErr
)
if
respath
[
2
]
==
"mas"
{
resvalid
=
true
cmapErr
,
httpErr
=
fe
.
handleMAS
(
w
,
r
)
}
default
:
cmapErr
=
errors
.
New
(
"Resource not found"
)
}
return
}
// handleMAS is the handler for requests to path /api/ams/mas
func
(
fe
*
Frontend
)
handleMAS
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
(
cmapErr
,
httpErr
error
)
{
if
r
.
Method
==
"GET"
{
// return short info of all MAS
var
mass
[]
schemas
.
MASInfoShort
mass
,
_
,
cmapErr
=
amsclient
.
GetMASsShort
()
if
cmapErr
!=
nil
{
httpErr
=
httpreply
.
Resource
(
w
,
mass
,
cmapErr
)
}
else
{
httpErr
=
httpreply
.
CMAPError
(
w
,
cmapErr
.
Error
())
}
}
else
if
r
.
Method
==
"POST"
{
}
else
{
httpErr
=
httpreply
.
MethodNotAllowed
(
w
)
cmapErr
=
errors
.
New
(
"Error: Method not allowed on path /api/clonemap/mas"
)
}
return
}
// listen opens a http server listening and serving request
func
(
fe
*
Frontend
)
listen
()
(
err
error
)
{
mux
:=
http
.
NewServeMux
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment