Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dataflow-filter-export #160

Merged
merged 2 commits into from Jan 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
60 changes: 0 additions & 60 deletions curl.go

This file was deleted.

128 changes: 0 additions & 128 deletions curl_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion context.go → dataflow/context.go
@@ -1,4 +1,4 @@
package gout
package dataflow

import (
"github.com/guonaihong/gout/decode"
Expand Down
8 changes: 4 additions & 4 deletions context_test.go → dataflow/context_test.go
@@ -1,4 +1,4 @@
package gout
package dataflow

import (
"github.com/gin-gonic/gin"
Expand Down Expand Up @@ -51,7 +51,7 @@ func TestContext_BindBodyJSON(t *testing.T) {
path := []string{"200", "500"}
count := 0
for _, p := range path {
err := Def().GET(ts.URL + "/" + p).Callback(func(c *Context) error {
err := New().GET(ts.URL + "/" + p).Callback(func(c *Context) error {
assert.NotEqual(t, c.Code, 404)

switch c.Code {
Expand Down Expand Up @@ -118,7 +118,7 @@ func TestContext_BindBodyYAML(t *testing.T) {
path := []string{"200", "500"}
count := 0
for _, p := range path {
err := Def().GET(ts.URL + "/" + p).Callback(func(c *Context) error {
err := New().GET(ts.URL + "/" + p).Callback(func(c *Context) error {
assert.NotEqual(t, c.Code, 404)

switch c.Code {
Expand Down Expand Up @@ -180,7 +180,7 @@ func TestContext_BindBodyXML(t *testing.T) {
path := []string{"200", "500"}
count := 0
for _, p := range path {
err := Def().GET(ts.URL + "/" + p).Callback(func(c *Context) error {
err := New().GET(ts.URL + "/" + p).Callback(func(c *Context) error {
assert.NotEqual(t, c.Code, 404)

switch c.Code {
Expand Down
29 changes: 19 additions & 10 deletions dataflow.go → dataflow/dataflow.go
@@ -1,4 +1,4 @@
package gout
package dataflow

import (
"context"
Expand Down Expand Up @@ -72,7 +72,7 @@ func (df *DataFlow) OPTIONS(url string) *DataFlow {

// SetHost set host
func (df *DataFlow) SetHost(host string) *DataFlow {
if df.err != nil {
if df.Err != nil {
return df
}

Expand All @@ -84,7 +84,7 @@ func (df *DataFlow) SetHost(host string) *DataFlow {

// SetURL set url
func (df *DataFlow) SetURL(url string) *DataFlow {
if df.err != nil {
if df.Err != nil {
return df
}

Expand Down Expand Up @@ -158,7 +158,7 @@ func (df *DataFlow) UnixSocket(path string) *DataFlow {

transport, ok := df.out.Client.Transport.(*http.Transport)
if !ok {
df.Req.err = fmt.Errorf("UnixSocket:not found http.transport:%T", df.out.Client.Transport)
df.Req.Err = fmt.Errorf("UnixSocket:not found http.transport:%T", df.out.Client.Transport)
return df
}

Expand All @@ -173,7 +173,7 @@ func (df *DataFlow) UnixSocket(path string) *DataFlow {
func (df *DataFlow) SetProxy(proxyURL string) *DataFlow {
proxy, err := url.Parse(modifyURL(proxyURL))
if err != nil {
df.Req.err = err
df.Req.Err = err
return df
}

Expand All @@ -183,7 +183,7 @@ func (df *DataFlow) SetProxy(proxyURL string) *DataFlow {

transport, ok := df.out.Client.Transport.(*http.Transport)
if !ok {
df.Req.err = fmt.Errorf("SetProxy:not found http.transport:%T", df.out.Client.Transport)
df.Req.Err = fmt.Errorf("SetProxy:not found http.transport:%T", df.out.Client.Transport)
return df
}

Expand Down Expand Up @@ -280,17 +280,26 @@ func (df *DataFlow) Debug(d ...interface{}) *DataFlow {
return df
}

func (df *DataFlow) IsDebug() bool {
return df.out.opt.Debug
}

// Do send function
func (df *DataFlow) Do() (err error) {
return df.Req.Do()
}

// Filter filter function, use this function to turn on the filter function
func (df *DataFlow) Filter() *Filter {
return &Filter{df: df}
func (df *DataFlow) Filter() *filter {
return &filter{df: df}
}

// Export filter function, use this function to turn on the filter function
func (df *DataFlow) Export() *Export {
return &Export{df: df}
func (df *DataFlow) Export() *export {
return &export{df: df}
}

func (df *DataFlow) SetGout(out *Gout) {
df.out = out
df.Req.g = out
}