package main
import (
"net/http"
"time"
"entrlcom.dev/http-request-body-json-decoder"
)
const maxBytes = 1 << (10 * 1) * 2 // 2 KiB.
type Request struct {
DateOfBirth time.Time `json:"date_of_birth"`
Email string `json:"email"`
Name string `json:"name"`
Password string `json:"password"`
}
func Handle(w http.ResponseWriter, r *http.Request) {
var request Request
// Decode HTTP request body to struct.
if err := http_request_body_json_decoder.Decode(w, r, &request, maxBytes); err != nil {
// TODO: Handle error.
return
}
// ...
}
-
Notifications
You must be signed in to change notification settings - Fork 0
HTTP request body JSON decoder
License
entrlcom/go-http-request-body-json-decoder
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
HTTP request body JSON decoder
Topics
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published