Skip to content

Commit

Permalink
removed hardcoded url
Browse files Browse the repository at this point in the history
  • Loading branch information
neel-bp committed Apr 6, 2023
1 parent 28a8fb5 commit faa5b0b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 3 additions & 0 deletions httpinterface/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package httpinterface

import (
"encoding/json"
"fmt"
"html/template"
"net/http"
"strings"
Expand Down Expand Up @@ -38,6 +39,7 @@ type StatusResponse struct {
ProjectName string `json:"projectName"`
DateTimeString string `json:"dateTimeString"`
Coverage float64 `json:"coverage"`
WebSocketRoute string `json:"websocketRoute"`
}

type WebsocketResponse struct {
Expand Down Expand Up @@ -192,6 +194,7 @@ func BuildStatus(w http.ResponseWriter, r *http.Request) {
ProjectName: projectID,
DateTimeString: result.LastBuildStart.Format(time.RFC3339),
Coverage: coverage,
WebSocketRoute: fmt.Sprintf(`ws://%s/%s/livestatus`, r.Host, projectID),
}

tmpl := template.Must(template.ParseFiles("statuspage.html"))
Expand Down
3 changes: 1 addition & 2 deletions statuspage.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ <h3 class="subtitle is-5" id="lastBuildStart">{{.DateTimeString}}</h3>

lastBuildStart.innerHTML = time;

// hardcoded url need to change later,
var socket = new WebSocket("ws://localhost:4444/vvfrontend/livestatus")
var socket = new WebSocket("{{.WebSocketRoute}}")

socket.onmessage = function (message) {
if (message.data != null) {
Expand Down

0 comments on commit faa5b0b

Please sign in to comment.