forked from goadesign/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
http.go
40 lines (35 loc) · 752 Bytes
/
http.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"net/http"
"os"
"time"
"github.com/go-kit/kit/endpoint"
goahttp "goa.design/goa/http"
cli "goa.design/plugins/goakit/examples/fetcher/fetcher/gen/http/cli/fetcher"
)
func doHTTP(scheme, host string, timeout int, debug bool) (endpoint.Endpoint, interface{}, error) {
var (
doer goahttp.Doer
)
{
doer = &http.Client{Timeout: time.Duration(timeout) * time.Second}
if debug {
doer = goahttp.NewDebugDoer(doer)
doer.(goahttp.DebugDoer).Fprint(os.Stderr)
}
}
return cli.ParseEndpoint(
scheme,
host,
doer,
goahttp.RequestEncoder,
goahttp.ResponseDecoder,
debug,
)
}
func httpUsageCommands() string {
return cli.UsageCommands()
}
func httpUsageExamples() string {
return cli.UsageExamples()
}