Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
RussellLuo committed Feb 26, 2022
1 parent 8800ed5 commit 5318772
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ See more examples [here](examples).
//kun:op <method> <pattern>
```
If a Go method needs to correspond to more than one URI (or HTTP method), you can specify multiple `//kun:op` directives, which will produce multiple HTTP request operations.
Note that the only differences among these HTTP request operations are the path parameters.
##### Arguments
- **method**: The request method.
Expand All @@ -324,15 +328,33 @@ See more examples [here](examples).
##### Examples
```go
type Service interface {
//kun:op DELETE /users/{id}
DeleteUser(ctx context.Context, id int) (err error)
}
- Single operation:
// HTTP request:
// $ http DELETE /users/101
```
```go
type Service interface {
//kun:op DELETE /users/{id}
DeleteUser(ctx context.Context, id int) (err error)
}
// HTTP request:
// $ http DELETE /users/101
```

- Multiple operations:

```go
type Service interface {
//kun:op GET /messages/{messageID}
//kun:op GET /users/{userID}/messages/{messageID}
GetMessage(ctx context.Context, userID string, messageID string) (text string, err error)
}

// See a runnable example in examples/messaging.

// HTTP request:
// $ http GET /messages/123456
// $ http GET /users/me/messages/123456
```

</details>

Expand Down

0 comments on commit 5318772

Please sign in to comment.