diff options
Diffstat (limited to 'example/example.go')
| -rw-r--r-- | example/example.go | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/example/example.go b/example/example.go index 332cbb3..1be51ef 100644 --- a/example/example.go +++ b/example/example.go @@ -31,8 +31,9 @@ import ( ) const ( - pathExample = "/example" - pathExampleError = "/example/error" + pathExample = `/example` + pathExampleError = `/example/error` + pathExampleNamePage = `/example/:name/page` ) const ( @@ -153,6 +154,14 @@ func (ex *Example) registerEndpoints() (err error) { Call: ex.pathExamplePost, }) + err = ex.trunks.Httpd.RegisterEndpoint(&libhttp.Endpoint{ + Method: libhttp.RequestMethodPost, + Path: pathExampleNamePage, + RequestType: libhttp.RequestTypeJSON, + ResponseType: libhttp.ResponseTypeJSON, + Call: ex.pathExamplePost, + }) + return err } @@ -289,6 +298,24 @@ func (ex *Example) registerTargets() (err error) { }, }, IsCustomizable: true, + }, { + Name: `HTTP Post path binding`, + Hint: `Test parameter with parameter in path`, + Method: libhttp.RequestMethodPost, + Path: pathExampleNamePage, + RequestType: libhttp.RequestTypeJSON, + Params: trunks.KeyFormInput{ + `name`: trunks.FormInput{ + Label: `Name`, + Hint: `This parameter send in path.`, + Value: `testname`, + }, + `id`: trunks.FormInput{ + Label: `ID`, + Hint: `This parameter send in body as JSON.`, + Value: `123`, + }, + }, }}, } |
