feat: initialize nuntius project with full server implementation
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
//go:build linux || freebsd
|
||||
|
||||
// Minimal example showing how to use the contactform package
|
||||
// standalone (without the HTTP server).
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"codeberg.org/petrbalvin/nuntius/pkg/contactform"
|
||||
)
|
||||
|
||||
func main() {
|
||||
req := &contactform.Request{
|
||||
Name: "Jane Doe",
|
||||
Email: "jane@example.com",
|
||||
Service: "architecture",
|
||||
Message: "Hi, I'd like to discuss a possible engagement.",
|
||||
}
|
||||
|
||||
if errs := contactform.Validate(req, "contact"); len(errs) > 0 {
|
||||
fmt.Fprintln(os.Stderr, "validation failed:")
|
||||
for _, e := range errs {
|
||||
fmt.Fprintf(os.Stderr, " - %s: %s\n", e.Field, e.Message)
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Println("Request is valid:")
|
||||
fmt.Printf(" name: %s\n", req.Name)
|
||||
fmt.Printf(" email: %s\n", req.Email)
|
||||
fmt.Printf(" service: %s\n", req.Service)
|
||||
fmt.Printf(" message: %s\n", req.Message)
|
||||
}
|
||||
Reference in New Issue
Block a user