Skip to content

Commit 9a215f5

Browse files
authored
repo: update readme with example (#5)
1 parent 61a880f commit 9a215f5

4 files changed

Lines changed: 36 additions & 4 deletions

File tree

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,38 @@ The `forms` package can be added to a project by running:
1414
go get cattlecloud.net/go/forms@latest
1515
```
1616

17+
```go
18+
import "cattlecloud.net/go/forms"
19+
```
20+
21+
### Examples
22+
23+
##### parsing http request
24+
25+
```go
26+
var (
27+
name string
28+
age int
29+
)
30+
31+
err := forms.Parse(request, forms.Schema{
32+
"NAME": forms.String(&name),
33+
"AGE": forms.Int(&age),
34+
})
35+
```
36+
37+
##### about requests
38+
39+
Typically the HTTP request will be given to you in the form of an http handler,
40+
e.g.
41+
42+
```go
43+
func(w http.ResponseWriter, r *http.Request) {
44+
_ = r.ParseForm()
45+
// now r form data is available to parse
46+
}
47+
```
48+
1749
### License
1850

1951
The `cattlecloud.net/go/forms` module is open source under the [BSD](LICENSE) license.

forms.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Copyright (c) CattleCloud LLC
22
// SPDX-License-Identifier: BSD-3-Clause
33

4-
// Package formdata provides a way to safely and conveniently extract html Form
4+
// Package forms provides a way to safely and conveniently extract html Form
55
// data using a definied schema.
6-
package formdata
6+
package forms
77

88
import (
99
"errors"

forms_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) CattleCloud LLC
22
// SPDX-License-Identifier: BSD-3-Clause
33

4-
package formdata
4+
package forms
55

66
import (
77
"context"

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module cattlecloud.net/go/forms
22

3-
go 1.23.4
3+
go 1.23
44

55
require (
66
github.com/shoenig/go-conceal v0.5.4

0 commit comments

Comments
 (0)