Netcore

Application Layer (Endpoint)

Overview

The Endpoint layer provides high-level message routing and request handling functionality.

Core Features

1. Route Registration

2. Request Context

3. Response Handling

Usage Examples

Basic Routing

from netcore import Endpoint, Response

@endpoint.route("hello")
def handle_hello():
    return Response("hello", "Hello World!")

@endpoint.route("echo")
def handle_echo():
    return Response("echo", request.data)

With Callbacks

def on_response(data, info):
    print(f"Received response: {data}")

endpoint.send("hello", "Hi!", callback=on_response)

Default Handler

@endpoint.default
def handle_default(data, info):
    print(f"Unhandled message: {data}")