Coder Social home page Coder Social logo

daniel-007 / boast Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dcb9/boast

0.0 0.0 0.0 917 KB

I want track all HTTP requests, and replay it easily.

Home Page: http://blog.phpor.me/note/2017/03/31/track-and-replay-http-request.html

License: MIT License

Makefile 1.26% Go 62.61% JavaScript 5.17% HTML 0.76% Vue 30.19%

boast's Introduction

中文

Boast

"I want track all requests, and replay it easily."

Usage

Install the boast package:

go get github.com/dcb9/boast

After installing, modify your server file

package main

import (
	"fmt"
	"net/http"
	"net/http/httptest"

	"github.com/dcb9/boast"
)

func main() {
	mux := http.NewServeMux()
	mux.HandleFunc("/", http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
		fmt.Fprintf(w, "Welcome to the home page!")
	}))

-	// the old way
-	http.ListenAndServe(":8080", mux)
+	// the boast way
+	server := httptest.NewServer(mux)
+	addr, debugAddr := ":8080", ":8079"
+	boast.Serve(server, addr, debugAddr)
}

Then run your server:

go run server.go

First request your server as usual, then you can visit debug panel ( http://localhost:8079 )

Standalone

Install

Download the latest binary file from the Releases page.

(darwin_amd64.tar.gz is for Mac OS X users)

Usage

$ cat .boast.json
{
	"debug_addr": ":8079",
	"list": [
		{ "url": "https://www.baidu.com/", "addr": ":8080" },
		{ "url": "https://github.com/", "addr": ":8081" }
	]
}

$ boast -c .boast.json

$ boast --help
Usage of boast:
  -c string
       config file path (default ".boast.json")

Sketch

HTTP Client                   Boast                       WebServer
| GET http://localhost:8080/   | Record and Reverse Proxy    | Response 200 OK
| ---------------------------> | --------------------------> | ------┐
|                              |                             |       |
|                              |     Record and Forward      |  <----┘
| <--------------------------- | <-------------------------- |

┌----------------------------------------------------------------------------┐
| url: http://localhost:8081                                                 |
| ---------------------------------------------------------------------------|
| All Transactions         ┌ - - - - - - - - - - - - - - - - - - - - - - - ┐ |
| ----------------------   | time: 10 hours ago  Client: 127.0.0.1         | |
| |GET / 200 OK 100 ms |   |                                               | |
| ----------------------   | Request                      [ Replay ]       | |
|                          | -   -   -   -   -   -   -   -   -   -   -   - | |
|                          | GET http://localhost/ HTTP/1.1                | |
|                          | User-Agent: curl/7.51.0                       | |
|                          | Accept: */*                                   | |
|                          |                                               | |
|                          | Response                                      | |
|                          | -   -   -   -   -   -   -   -   -   -   -   - | |
|                          | HTTP/1.1 200 OK                               | |
|                          | X-Server: HTTPLab                             | |
|                          | Date: Thu, 02 Mar 2017 02:25:27 GMT           | |
|                          | Content-Length: 13                            | |
|                          | Content-Type: text/plain; charset=utf-8       | |
|                          |                                               | |
|                          | Hello, World                                  | |
|                          └ - - - - - - - - - - - - - - - - - - - - - - - ┘ |
|                                                                            |
└----------------------------------------------------------------------------┘

Warning

DO NOT USE ON PRODUCTION!

Boast is heavily inspired by ngrok.

boast's People

Contributors

dcb9 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.