examples

package
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthMiddleware

func AuthMiddleware() contractshttp.HandlerFunc

Middleware example

func CleanAuthMiddleware

func CleanAuthMiddleware() contractshttp.Middleware

func CleanCreateUserHandler

func CleanCreateUserHandler(ctx contractshttp.Context) contractshttp.Response

func CleanDeleteUserHandler

func CleanDeleteUserHandler(ctx contractshttp.Context) contractshttp.Response

func CleanGetUserHandler

func CleanGetUserHandler(ctx contractshttp.Context) contractshttp.Response

Handlers

func CleanUpdateUserHandler

func CleanUpdateUserHandler(ctx contractshttp.Context) contractshttp.Response

func CreateUserHandler

func CreateUserHandler(ctx contractshttp.Context) contractshttp.Response

func DeleteUserHandler

func DeleteUserHandler(ctx contractshttp.Context) contractshttp.Response

func GetUserHandler

func GetUserHandler(ctx contractshttp.Context) contractshttp.Response

Handlers

func SetupBasicRoutes

func SetupBasicRoutes()

Example 1: Basic usage with Tonic routes

func SetupCleanTonicRoutes

func SetupCleanTonicRoutes()

Example 1: Clean API - extends existing Goravel routes with Tonic

func SetupCleanTypedRoutes

func SetupCleanTypedRoutes()

Example 2: Clean API with typed routes

func SetupCleanWithMiddleware

func SetupCleanWithMiddleware()

Example 3: Works with existing Goravel middleware

func SetupGroupRoutes

func SetupGroupRoutes()

Example 2: Using Group methods for Tonic routes

func SetupRoutesWithMiddleware

func SetupRoutesWithMiddleware()

Example 3: With middleware

func UpdateUserHandler

func UpdateUserHandler(ctx contractshttp.Context) contractshttp.Response

Types

type CleanCreateUserRequest

type CleanCreateUserRequest struct {
	Name  string `json:"name" binding:"required" description:"User's full name"`
	Email string `json:"email" binding:"required,email" description:"User's email address"`
}

type CleanGetUserRequest

type CleanGetUserRequest struct {
	ID string `uri:"id" binding:"required" json:"id" description:"User ID"`
}

Clean example request/response types

type CleanUserResponse

type CleanUserResponse struct {
	ID    string `json:"id" description:"User ID"`
	Name  string `json:"name" description:"User's full name"`
	Email string `json:"email" description:"User's email address"`
}

type CreateUserRequest

type CreateUserRequest struct {
	Name  string `json:"name" binding:"required" description:"User's full name"`
	Email string `json:"email" binding:"required,email" description:"User's email address"`
}

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error" description:"Error message"`
}

type GetUserRequest

type GetUserRequest struct {
	ID string `uri:"id" binding:"required" json:"id" description:"User ID"`
}

Example request/response types

type UserResponse

type UserResponse struct {
	ID    string `json:"id" description:"User ID"`
	Name  string `json:"name" description:"User's full name"`
	Email string `json:"email" description:"User's email address"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL