Commit a237ea6b authored by Stefan Dähling's avatar Stefan Dähling
Browse files

some fixes

parent 5f6b473b
Pipeline #301491 passed with stages
in 3 minutes and 18 seconds
......@@ -50,6 +50,7 @@ COPY cmd/frontend cmd/frontend
COPY pkg/frontend pkg/frontend
COPY pkg/common pkg/common
COPY pkg/schemas pkg/schemas
COPY pkg/ams/client pkg/ams/client
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/
......
......@@ -65,8 +65,8 @@ func (fe *Frontend) handleAPI(w http.ResponseWriter, r *http.Request) {
if len(respath) > 2 {
switch respath[2] {
case "ams":
cmapErr, httpErr = fe.handleAMS(w, r, respath)
resvalid = true
resvalid, cmapErr, httpErr = fe.handleAMS(w, r, respath)
// resvalid = true
case "df":
case "logger":
default:
......@@ -88,11 +88,11 @@ 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) (resvalid bool, cmapErr, httpErr error) {
respath []string) (resvalid bool, cmapErr error, httpErr error) {
resvalid = false
switch len(respath) {
case 3:
if respath[2] == "mas" {
case 4:
if respath[3] == "mas" {
resvalid = true
cmapErr, httpErr = fe.handleMAS(w, r)
}
......@@ -108,7 +108,7 @@ func (fe *Frontend) handleMAS(w http.ResponseWriter, r *http.Request) (cmapErr,
// return short info of all MAS
var mass []schemas.MASInfoShort
mass, _, cmapErr = amsclient.GetMASsShort()
if cmapErr != nil {
if cmapErr == nil {
httpErr = httpreply.Resource(w, mass, cmapErr)
} else {
httpErr = httpreply.CMAPError(w, cmapErr.Error())
......@@ -126,7 +126,7 @@ func (fe *Frontend) handleMAS(w http.ResponseWriter, r *http.Request) (cmapErr,
func (fe *Frontend) listen() (err error) {
mux := http.NewServeMux()
mux.HandleFunc("/api/", fe.handleAPI)
mux.HandleFunc("/", http.FileServer(http.Dir("../../web")).ServeHTTP)
mux.HandleFunc("/", http.FileServer(http.Dir("./web")).ServeHTTP)
s := &http.Server{
Addr: ":13000",
Handler: mux,
......
......@@ -11,7 +11,7 @@ $(document).ready(function(){
function sideoverview(){
$(".modules").hide();
$("#headertitle").text("Overview");
fetch('/api/ams').then(response => response.json()).then(data => console.log(data));
fetch('/api/ams/mas').then(response => response.json()).then(data => console.log(data));
}
function sideplatform(){
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment