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
5d1da0b2
Commit
5d1da0b2
authored
Jun 28, 2020
by
Stefan Dähling
Browse files
started with frontend server
parent
bb1fcb48
Pipeline
#300529
passed with stages
in 3 minutes and 33 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
build/docker/frontend/Dockerfile
0 → 100644
View file @
5d1da0b2
# Copyright 2020 Institute for Automation of Complex Power Systems,
# E.ON Energy Research Center, RWTH Aachen University
#
# This project is licensed under either of
# - Apache License, Version 2.0
# - MIT License
# at your option.
#
# Apache License, Version 2.0:
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# MIT License:
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
FROM
golang:1.13.8 AS fe_builder
WORKDIR
/clonemap
COPY
go.mod .
COPY
go.sum .
RUN
go mod download
COPY
cmd/frontend cmd/frontend
COPY
pkg/frontend pkg/frontend
COPY
pkg/common pkg/common
COPY
web web
ENV
PATH="/clonemap:${PATH}"
RUN
cd
cmd/frontend
;
CGO_ENABLED
=
0
GOOS
=
linux go build
-ldflags
'-s'
-o
frontend
;
cp
frontend /clonemap/
FROM
alpine:latest
WORKDIR
/root/
#RUN apk add --update netbase ca-certificates
COPY
--from=fe_builder /clonemap/frontend .
COPY
--from=fe_builder /clonemap/web ./web
EXPOSE
30013
CMD
["./frontend"]
cmd/frontend/main.go
0 → 100644
View file @
5d1da0b2
/*
Copyright 2020 Institute for Automation of Complex Power Systems,
E.ON Energy Research Center, RWTH Aachen University
This project is licensed under either of
- Apache License, Version 2.0
- MIT License
at your option.
Apache License, Version 2.0:
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
MIT License:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package
main
import
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/frontend"
func
main
()
{
frontend
.
StartFrontend
()
return
}
pkg/frontend/frontend.go
0 → 100644
View file @
5d1da0b2
/*
Copyright 2020 Institute for Automation of Complex Power Systems,
E.ON Energy Research Center, RWTH Aachen University
This project is licensed under either of
- Apache License, Version 2.0
- MIT License
at your option.
Apache License, Version 2.0:
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
MIT License:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package
frontend
import
(
"errors"
"net/http"
"strings"
"git.rwth-aachen.de/acs/public/cloud/mas/clonemap/pkg/common/httpreply"
)
// Frontend frontend
type
Frontend
struct
{
}
// StartFrontend start
func
StartFrontend
()
(
err
error
)
{
fe
:=
&
Frontend
{}
fe
.
listen
()
return
}
// handleAPI is the global handler for requests to path /api
func
(
fe
*
Frontend
)
handleAPI
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
var
cmapErr
,
httpErr
error
// ams.logInfo.Println("Received Request: ", r.Method, " ", r.URL.EscapedPath())
// determine which ressource is requested and call corresponding handler
respath
:=
strings
.
Split
(
r
.
URL
.
EscapedPath
(),
"/"
)
resvalid
:=
false
switch
len
(
respath
)
{
case
2
:
resvalid
=
true
default
:
cmapErr
=
errors
.
New
(
"Resource not found"
)
}
if
!
resvalid
{
httpErr
=
httpreply
.
NotFoundError
(
w
)
cmapErr
=
errors
.
New
(
"Resource not found"
)
}
if
cmapErr
!=
nil
{
// ams.logError.Println(respath, cmapErr)
}
if
httpErr
!=
nil
{
// ams.logError.Println(respath, httpErr)
}
}
// listen opens a http server listening and serving request
func
(
fe
*
Frontend
)
listen
()
(
err
error
)
{
mux
:=
http
.
NewServeMux
()
mux
.
HandleFunc
(
"/api/"
,
fe
.
handleAPI
)
mux
.
HandleFunc
(
"/"
,
http
.
FileServer
(
http
.
Dir
(
"./web"
))
.
ServeHTTP
)
s
:=
&
http
.
Server
{
Addr
:
":13000"
,
Handler
:
mux
,
}
err
=
s
.
ListenAndServe
()
return
}
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