# Routes

{% hint style="info" %}
Please see [Mandarine MVC Controllers](https://mandarineframework.gitbook.io/mandarine-ts/mandarine-mvc/web-mvc/controllers) before continuing.&#x20;
{% endhint %}

## Declaring routes

Routes are declared by using specific decorators, these decorators have two parameters:

* Route (*string*):
  * Required
  * Route of the endpoint
    * If the parent [controller](https://mandarineframework.gitbook.io/mandarine-ts/mandarine-core/components/controller#usage) contains a base route, then they will be unified.
* options ([*Mandarine.MandarineMVC.Routing.RoutingOptions*](https://doc.deno.land/https/raw.githubusercontent.com/mandarineorg/mandarinets/master/mvc-framework/mandarine-mvc.ns.ts#MandarineMvc.Routing.RoutingOptions)):
  * Optional
  * Contains:
    * responseStatus ([HttpStatusCode](https://doc.deno.land/https/raw.githubusercontent.com/mandarineorg/mandarinets/master/mvc-framework/mandarine-mvc.ns.ts#MandarineMvc.HttpStatusCode)): Default response status for endpoint.

#### Types of routes available

[See enum here](https://doc.deno.land/https/raw.githubusercontent.com/mandarineorg/mandarinets/master/mvc-framework/mandarine-mvc.ns.ts#MandarineMvc.HttpMethods)

* GET
* POST
* PUT
* HEAD
* DELETE
* OPTIONS
* PATCH

## Usage

**Syntax:**

{% tabs %}
{% tab title="Declaration" %}

```typescript
import { GET, POST, PUT, HEAD, DELETE, OPTIONS, PATCH, CONTROLLER, MandarineCore } from "https://deno.land/x/mandarinets/mod.ts";

@Controller()
export class MyController {
    
    @GET('/hello-world')
    public httpHandler() {
        return "You have requested me. Hello World";
    }
    
}

new MandarineCore().MVC().run();
```

{% endtab %}

{% tab title="Test" %}
Request

```
# http://localhost:8080/hello-world
You have requested me. Hello World
```

{% endtab %}
{% endtabs %}

Note that in the example above we are only using **GET,** but all the route types listed above are available to be used. For example, if you would like to use **POST** instead of **GET,** it would be:

```typescript
import { GET, POST, PUT, HEAD, DELETE, OPTIONS, PATCH, CONTROLLER, MandarineCore } from "https://deno.land/x/mandarinets/mod.ts";

@Controller()
export class MyController {
    ...
    @POST('/hello-world')
    ...
}

new MandarineCore().MVC().run();
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mandarineframework.gitbook.io/mandarine-ts/mandarine-mvc/controllers/using-routes-and-http-handlers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
