Endpoint Generator

The endpoint generator creates HTTP request handlers for your Azu application. Endpoints handle incoming HTTP requests and return typed responses.

Overview

azu generate endpoint <name> [options]

Basic Usage

# Generate endpoint with default index action
azu generate endpoint users

# Generate with namespace
azu generate endpoint admin/users

# Generate API endpoint
azu generate endpoint api/v1/users --api

# Generate with specific actions
azu generate endpoint posts --actions index,show,create,update,destroy

Command Options

Option
Description
Default

--api

Generate API-only endpoints

false

--actions <list>

Comma-separated actions to generate

index

--force

Overwrite existing files

false

Generated Files

Endpoint Structure

Endpoints use include Azu::Endpoint(RequestType, ResponseType) with HTTP verb macros.

Index Endpoint

Show Endpoint

Create Endpoint

Update Endpoint

Destroy Endpoint

Request Types

Requests use include Azu::Request with validation.

Response Types

Responses use include Azu::Response with JSON serialization.

Page Types (Web Endpoints)

Pages use include Azu::Response with template rendering.

HTTP Verb Macros

Macro
HTTP Method
Example

get

GET

get "/users"

post

POST

post "/users"

put

PUT

put "/users/:id"

patch

PATCH

patch "/users/:id"

delete

DELETE

delete "/users/:id"

Accessing Request Data

Error Handling

Examples

API Endpoints

Nested Resources

Generated path: /posts/:post_id/comments


Next Steps:

Last updated