add goa examples
This commit is contained in:
39
go/goa_example/cmd/host-cli/http.go
Normal file
39
go/goa_example/cmd/host-cli/http.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
cli "goa_example/gen/http/cli/host"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
goahttp "goa.design/goa/v3/http"
|
||||
goa "goa.design/goa/v3/pkg"
|
||||
)
|
||||
|
||||
func doHTTP(scheme, host string, timeout int, debug bool) (goa.Endpoint, interface{}, error) {
|
||||
var (
|
||||
doer goahttp.Doer
|
||||
)
|
||||
{
|
||||
doer = &http.Client{Timeout: time.Duration(timeout) * time.Second}
|
||||
if debug {
|
||||
doer = goahttp.NewDebugDoer(doer)
|
||||
}
|
||||
}
|
||||
|
||||
return cli.ParseEndpoint(
|
||||
scheme,
|
||||
host,
|
||||
doer,
|
||||
goahttp.RequestEncoder,
|
||||
goahttp.ResponseDecoder,
|
||||
debug,
|
||||
)
|
||||
}
|
||||
|
||||
func httpUsageCommands() string {
|
||||
return cli.UsageCommands()
|
||||
}
|
||||
|
||||
func httpUsageExamples() string {
|
||||
return cli.UsageExamples()
|
||||
}
|
||||
Reference in New Issue
Block a user