Skip to content

Commit

Permalink
fix: Fix create http routes command (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
nt0xa authored Mar 31, 2021
1 parent 15c51ee commit a9fbcf7
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 64 deletions.
47 changes: 0 additions & 47 deletions coverage.outgo

This file was deleted.

18 changes: 1 addition & 17 deletions internal/actions/http_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/base64"
"fmt"
"io/ioutil"
"regexp"
"strconv"
"strings"
Expand Down Expand Up @@ -79,7 +78,6 @@ func HTTPRoutesCreateCommand(p *HTTPRoutesCreateParams) (*cobra.Command, Prepare

var (
headers []string
file bool
)

cmd.Flags().StringVarP(&p.PayloadName, "payload", "p", "", "Payload name")
Expand All @@ -90,9 +88,6 @@ func HTTPRoutesCreateCommand(p *HTTPRoutesCreateParams) (*cobra.Command, Prepare
cmd.Flags().IntVarP(&p.Code, "code", "c", 200, "Response status code")
cmd.Flags().BoolVarP(&p.IsDynamic, "dynamic", "d", false, "Interpret body and headers as templates")

// TODO: only for console client
cmd.Flags().BoolVarP(&file, "file", "f", false, "Treat BODY as path to file")

return cmd, func(cmd *cobra.Command, args []string) errors.Error {
hh := make(map[string][]string)
for _, header := range headers {
Expand All @@ -110,18 +105,7 @@ func HTTPRoutesCreateCommand(p *HTTPRoutesCreateParams) (*cobra.Command, Prepare
}
p.Headers = hh

var body []byte

if file {
b, err := ioutil.ReadFile(args[0])
if err != nil {
return errors.Validationf("fail to read file %q", args[0])
}
body = b
} else {
body = []byte(args[0])
}

body := []byte(args[0])
p.Body = base64.StdEncoding.EncodeToString(body)

return nil
Expand Down

0 comments on commit a9fbcf7

Please sign in to comment.