-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// SPDX-FileCopyrightText: 2024 caixw | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
// Package yaml 支持 YAML 编码的序列化操作 | ||
package yaml | ||
|
||
import ( | ||
"io" | ||
|
||
"gopkg.in/yaml.v3" | ||
|
||
"github.com/issue9/web" | ||
) | ||
|
||
const ( | ||
Mimetype = "application/yaml" | ||
ProblemMimetype = "application/problem+yaml" | ||
) | ||
|
||
func Marshal(_ *web.Context, v any) ([]byte, error) { return yaml.Marshal(v) } | ||
|
||
func Unmarshal(r io.Reader, v any) error { return yaml.NewDecoder(r).Decode(v) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// SPDX-FileCopyrightText: 2024 caixw | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
package yaml | ||
|
||
import "github.com/issue9/web" | ||
|
||
var ( | ||
_ web.MarshalFunc = Marshal | ||
_ web.UnmarshalFunc = Unmarshal | ||
) |