mirror of
https://github.com/foomo/gotsrpc.git
synced 2025-10-16 12:35:35 +00:00
fix: remove demo code
This commit is contained in:
parent
094ce278f3
commit
dffe7a09c0
@ -1,54 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
|
||||||
"os/exec"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/foomo/gotsrpc/v2/demo"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Demo struct {
|
|
||||||
proxy *demo.DemoGoTSRPCProxy
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *Demo) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
||||||
switch r.URL.Path {
|
|
||||||
case "/demo.js":
|
|
||||||
serveFile("demo.js", w)
|
|
||||||
case "/":
|
|
||||||
serveFile("index.html", w)
|
|
||||||
default:
|
|
||||||
switch true {
|
|
||||||
case strings.HasPrefix(r.URL.Path, "/service"):
|
|
||||||
d.proxy.ServeHTTP(w, r)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func serveFile(name string, w http.ResponseWriter) {
|
|
||||||
index, err := ioutil.ReadFile(name)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
w.Write(index)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
d := &Demo{
|
|
||||||
proxy: demo.NewDefaultDemoGoTSRPCProxy(&demo.Demo{}),
|
|
||||||
}
|
|
||||||
fmt.Println("starting a demo server on http://127.0.0.1:8080 - open it and take a look at the console")
|
|
||||||
cmd := exec.Command("open", "http://127.0.0.1:8080")
|
|
||||||
go func() {
|
|
||||||
err := cmd.Run()
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("tried to open things with you default browser - did fail", err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
fmt.Println(http.ListenAndServe(":8080", d))
|
|
||||||
}
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
/// <reference path="output/demo.ts"/>
|
|
||||||
/// <reference path="output/demo-nested.ts"/>
|
|
||||||
/// <reference path="output/client.ts"/>
|
|
||||||
var handleCrap = function (err, request) {
|
|
||||||
if (err) {
|
|
||||||
console.log("fuckit logic");
|
|
||||||
}
|
|
||||||
else if (request) {
|
|
||||||
console.warn("request crap", request);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.log("no crap", err);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
GoTSRPC.Demo.DemoClient.defaultInst.hello("Hansi", function (reply, err) {
|
|
||||||
console.log("server says hello to Hansi", reply, err);
|
|
||||||
handleCrap(err, null);
|
|
||||||
}, function (request) {
|
|
||||||
console.log("wtf", request);
|
|
||||||
handleCrap(null, request);
|
|
||||||
});
|
|
||||||
GoTSRPC.Demo.DemoClient.defaultInst.hello("Peter", function (reply, err) {
|
|
||||||
console.log("server should not like Peter, sorry Peter ;)", reply, err);
|
|
||||||
handleCrap(err, null);
|
|
||||||
}, function (request) {
|
|
||||||
console.log("wtf", request);
|
|
||||||
handleCrap(null, request);
|
|
||||||
});
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>service test</title>
|
|
||||||
<script src="/demo.js"></script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>A service test</h1>
|
|
||||||
<code><pre>open the console!</pre></code>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Loading…
Reference in New Issue
Block a user