Skip to content
This repository has been archived by the owner on Oct 24, 2018. It is now read-only.

Commit

Permalink
remove replay implemention
Browse files Browse the repository at this point in the history
  • Loading branch information
dcb9 committed Jun 20, 2018
1 parent 831d8be commit f3c9c56
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 146 deletions.
18 changes: 1 addition & 17 deletions frontend/src/components/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@
</div>
<hr />
<div>
<h3 class="row">
<div class="col-4">Request</div>
<div class="col-8"><button class="btn replay" v-on:click="replay(cts.ID)">Replay</button></div>
</h3>
<h3 class="row">Request</h3>
<div>
<p><a v-on:click="doDownloadCurl()" href="javascript:;">show cURL command</a></p>
<span v-if="downloadCurl"><a target="_blank" href="https://www.getpostman.com/docs/importing_curl">Tips</a></span>
Expand Down Expand Up @@ -178,9 +175,6 @@
this.cts = t;
this.downloadCurl = false;
},
replay: function(id) {
this.wsConn.send(JSON.stringify({Action: "replay", ID: id}))
},
doDownloadCurl: function() {
this.downloadCurl = !this.downloadCurl;
}
Expand All @@ -204,19 +198,9 @@

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style>
.replay {
cursor: pointer;
float:right;
border-radius: 0;
}
.alert {
border-radius: 0;
}
.replay:hover {
background-color: #ff9999;
background-color: #000000;
color:white;
}
.clientIP {
margin-left: 8px;
}
Expand Down
19 changes: 0 additions & 19 deletions transaction/serve.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package transaction

import (
"bytes"
"io/ioutil"
"log"
"net/http"
"net/url"

"github.com/dcb9/boast/config"
"github.com/google/uuid"
)

var TxHub *Hub
Expand All @@ -29,19 +26,3 @@ func Serve() {
go http.ListenAndServe(rp.Addr, proxy)
}
}

func Replay(id uuid.UUID) {
tx := TxHub.Transactions[id]

body := ioutil.NopCloser(bytes.NewReader(tx.Req.Body))
req, err := http.NewRequest(tx.Req.Method, tx.Req.URL.String(), body)
if err != nil {
log.Println(err)
return
}
req.Header = CopyHeader(tx.Req.Header)
_, err = transport.RoundTrip(req)
if err != nil {
log.Println(err)
}
}
174 changes: 87 additions & 87 deletions web/bindata_assetfs.go

Large diffs are not rendered by default.

18 changes: 0 additions & 18 deletions web/ws/api.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package ws

import (
"log"
"time"

"github.com/dcb9/boast/transaction"
"github.com/google/uuid"
)

Expand All @@ -28,19 +26,3 @@ type Transaction struct {
BeginAt time.Time `json:"BeginAt"`
EndAt time.Time `json:"EndAt"`
}

type ReceivedMessage struct {
Action string `json:"Action"`
ID string `json:"ID"`
}

func (m *ReceivedMessage) Do() {
switch m.Action {
case "replay":
if id, err := uuid.Parse(m.ID); err != nil {
log.Println(err)
} else {
transaction.Replay(id)
}
}
}
6 changes: 1 addition & 5 deletions web/ws/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ func (c *Client) readPump() {
}
break
}
m := &ReceivedMessage{}
if err := json.Unmarshal(message, m); err != nil {
log.Println(err)
}
m.Do()
log.Println("received message: ", string(message))
}
}

Expand Down

0 comments on commit f3c9c56

Please sign in to comment.