https://github.com/code-hex/why-need-validation-on-the-backend
Why need validation on the backend?
https://github.com/code-hex/why-need-validation-on-the-backend
Last synced: 3 months ago
JSON representation
Why need validation on the backend?
- Host: GitHub
- URL: https://github.com/code-hex/why-need-validation-on-the-backend
- Owner: Code-Hex
- License: mit
- Created: 2021-09-30T16:11:32.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2021-09-30T16:14:01.000Z (about 4 years ago)
- Last Synced: 2025-02-05T14:39:04.618Z (10 months ago)
- Language: Go
- Size: 4.88 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Why need validation on the backend?
This project is an appendix for my blog [article (about validation)](https://codehex.dev/notes/about_validation).
This application has a scenario.
> Once upon a time, There was a war between the banana faction and the orange faction. One day, somebody said, “I’ve developed the voting application to prove which is better fruits!”
Now, which one will you vote for? Voting for any other fruit is a sin.

## How to setup and runs this?
```
go run main.go
```
and go to `http://127.0.0.1:1323` with your browser.
## Cheat
You can vote for other fruit this way.
```
$ curl 'http://127.0.0.1:1323/vote' -H 'Content-Type: application/x-www-form-urlencoded' --data-raw 'fruit=apple'
```
## Refs
- https://stackoverflow.com/a/162579