func inputTransformer()

in cmd/http/http.go [48:70]


func inputTransformer(ssl bool, target string) input.Transformer {
	protocol := "http"
	if ssl {
		protocol = "https"
	}

	return func(input string) (interface{}, error) {
		i := strings.Index(input, " ")
		if i < 0 {
			return nil, fmt.Errorf("%w, want: %s, got: %q", errors.ErrInvalidFormat, formats, input)
		}

		method, data := input[:i], input[i+1:]
		switch method {
		case "GET":
			return parseGetRequest(protocol, target, data)
		case "POST":
			return parsePostRequest(protocol, target, data)
		}

		return nil, fmt.Errorf("%w, want: (GET|POST), got: %q", errors.ErrInvalidFormat, method)
	}
}