Skip to content
This repository was archived by the owner on Feb 16, 2023. It is now read-only.

Commit a7e8e23

Browse files
Merge pull request #195 from secrethub/fix/demo-app-api-url
Use relative url in demo app
2 parents d5df021 + 82a6fc2 commit a7e8e23

2 files changed

Lines changed: 3 additions & 8 deletions

File tree

internals/demo/app/page.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const page = `
6767
}
6868
6969
$(function(){
70-
$.get("http://127.0.0.1:{{.}}/api", {}, function(res, status, xhr){
70+
$.get("/api", {}, function(res, status, xhr){
7171
if(xhr.status === 200) {
7272
processResult("Successfully connected to https://demo.secrethub.io/api!", "check", "green", res);
7373
} else {

internals/demo/app/serve.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package app
22

33
import (
44
"fmt"
5-
"html/template"
65
"io"
76
"net/http"
87
"os"
@@ -37,13 +36,9 @@ func (s *Server) Serve() error {
3736
}
3837

3938
func (s *Server) ServeIndex(w http.ResponseWriter, r *http.Request) {
40-
tmpl, err := template.New("tpl").Parse(page)
39+
_, err := w.Write([]byte(page))
4140
if err != nil {
42-
panic(err)
43-
}
44-
err = tmpl.Execute(w, s.port)
45-
if err != nil {
46-
panic(err)
41+
w.WriteHeader(http.StatusInternalServerError)
4742
}
4843
}
4944

0 commit comments

Comments
 (0)