mirror of
https://github.com/aykhans/dodo.git
synced 2025-09-05 10:43:37 +00:00
🔨 Refactor all requests package logic.
- Replace net/http with fasthttp in the requests package.
This commit is contained in:
47
main.go
47
main.go
@@ -1,18 +1,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/aykhans/dodo/config"
|
||||
"github.com/aykhans/dodo/custom_errors"
|
||||
customerrors "github.com/aykhans/dodo/custom_errors"
|
||||
"github.com/aykhans/dodo/readers"
|
||||
"github.com/aykhans/dodo/requests"
|
||||
"github.com/aykhans/dodo/utils"
|
||||
"github.com/aykhans/dodo/validation"
|
||||
goValidator "github.com/go-playground/validator/v10"
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -61,9 +61,13 @@ func main() {
|
||||
)
|
||||
}
|
||||
|
||||
dodoConf := &config.DodoConfig{
|
||||
parsedURL, err := url.Parse(conf.URL)
|
||||
if err != nil {
|
||||
utils.PrintErrAndExit(err)
|
||||
}
|
||||
dodoConf := &config.RequestConfig{
|
||||
Method: conf.Method,
|
||||
URL: conf.URL,
|
||||
URL: parsedURL,
|
||||
Timeout: time.Duration(conf.Timeout) * time.Millisecond,
|
||||
DodosCount: conf.DodosCount,
|
||||
RequestCount: conf.RequestCount,
|
||||
@@ -73,39 +77,8 @@ func main() {
|
||||
Proxies: jsonConf.Proxies,
|
||||
Body: jsonConf.Body,
|
||||
}
|
||||
|
||||
dodoConf.Print()
|
||||
responses, err := requests.Run(dodoConf)
|
||||
if err != nil {
|
||||
utils.PrintErrAndExit(err)
|
||||
}
|
||||
|
||||
t := table.NewWriter()
|
||||
t.SetOutputMirror(os.Stdout)
|
||||
t.SetStyle(table.StyleLight)
|
||||
t.AppendHeader(table.Row{
|
||||
"Response",
|
||||
"Count",
|
||||
"Min Time",
|
||||
"Max Time",
|
||||
"Average Time",
|
||||
})
|
||||
for _, mergedResponse := range responses.MergeDodoResponses() {
|
||||
t.AppendRow(table.Row{
|
||||
mergedResponse.Response,
|
||||
mergedResponse.Count,
|
||||
mergedResponse.MinTime,
|
||||
mergedResponse.MaxTime,
|
||||
mergedResponse.AvgTime,
|
||||
})
|
||||
t.AppendSeparator()
|
||||
}
|
||||
t.AppendFooter(table.Row{
|
||||
"Total",
|
||||
responses.Len(),
|
||||
responses.MinTime(),
|
||||
responses.MaxTime(),
|
||||
responses.AvgTime(),
|
||||
})
|
||||
t.Render()
|
||||
responses := requests.Run(dodoConf)
|
||||
responses.Print()
|
||||
}
|
||||
|
Reference in New Issue
Block a user