# 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();
```
