Skip to content

Commit

Permalink
Add http route docs
Browse files Browse the repository at this point in the history
  • Loading branch information
255kb committed Aug 23, 2024
1 parent bbb9506 commit 04b347a
Show file tree
Hide file tree
Showing 29 changed files with 56 additions and 13 deletions.
20 changes: 11 additions & 9 deletions components/nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,6 @@ const Nav: FunctionComponent = function () {
<div className='col-12 col-lg-6'>
<h6 className='dropdown-header'>Learn</h6>

<Link
href='/training/'
className={`dropdown-item ${
router.pathname === '/training' ? 'active' : ''
}`}
>
Live Training{' '}
<i className='icon-new_releases text-warning'></i>
</Link>
<Link
href='/docs/latest/about/'
className={`dropdown-item ${
Expand All @@ -238,6 +229,7 @@ const Nav: FunctionComponent = function () {
>
Docs
</Link>

<Link
href='/tutorials/'
className={`dropdown-item ${
Expand All @@ -249,6 +241,16 @@ const Nav: FunctionComponent = function () {
>
Tutorials
</Link>

<Link
href='/training/'
className={`dropdown-item ${
router.pathname === '/training' ? 'active' : ''
}`}
>
Live Training{' '}
<i className='icon-new_releases text-warning'></i>
</Link>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion content/compare/mock-service-worker.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ order: 8

Mock Service Worker (MSW) is a **JavaScript library** that enables developers to **intercept** and **mock** network requests at the browser or Node.js level. It works by creating a service worker that captures outgoing HTTP requests, allowing developers to define custom responses for testing and debugging purposes. MSW is commonly used to simulate API responses during the development process, enabling testing without relying on actual backend services. It supports REST, GraphQL, and other request formats, making it versatile for various use cases in front-end and back-end development. MSW operates as an alternative to other API mocking tools like Mockoon.

![#sub#Screenshot of Mock Service Worker's code](/images/compare/api-mocking-comparison-mock-service-worker-screenshot.png)
![#sub#Screenshot of Mock Service Worker's code{1755x774}](/images/compare/api-mocking-comparison-mock-service-worker-screenshot.png)

## What is Mockoon?

Expand Down
6 changes: 3 additions & 3 deletions content/docs/latest/api-endpoints/crud-routes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: CRUD routes
meta:
title: Mockoon CRUD routes documentation
description: All you need to know about Mockoon's mock API CRUD routes creation, behavior, data bucket operations and data manipulation.
order: 210
order: 220
---

# CRUD routes
Expand All @@ -12,7 +12,7 @@ order: 210

## Overview

Where Mockoon routes are independent and stateless, CRUD routes can generate multiple endpoints to perform CRUD operations (Create, Read, Update, Delete) on [data buckets](docs:data-buckets/overview). Data buckets are generated when the server start, their state persisting between calls. It makes them the perfect tool to simulate small databases.
Where Mockoon routes are [independent and stateless](docs:api-endpoints/http-routes), CRUD routes can generate multiple endpoints to perform CRUD operations (Create, Read, Update, Delete) on [data buckets](docs:data-buckets/overview). Data buckets are generated when the server start, their state persisting between calls. It makes them the perfect tool to simulate small databases.

A CRUD endpoint will automatically create a series of routes during runtime, allowing you to perform actions on your data bucket. A typical example is an array of resources (users, invoices, etc.) you can update through a PUT request and see the result in a subsequent GET request.

Expand All @@ -24,7 +24,7 @@ Then, set its path, usually a [resource name](/articles/api-guide-rest-api-compo

![Set the CRUD route path{1484x176}](docs-img:set-crud-route-path.png)

> Your path can be more complex, and contains parameters or multiple sections. Remember that this will be the "prefix" of the different endpoints (see below).
> 💡 Your path can be more complex, and contains parameters or multiple sections. Remember that this will be the "prefix" of the different endpoints (see below).
## Data bucket link

Expand Down
41 changes: 41 additions & 0 deletions content/docs/latest/api-endpoints/http-routes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
title: HTTP routes
meta:
title: Mockoon HTTP routes documentation
description: All you need to know about Mockoon's mock API HTTP routes creation, behavior, custom body, headers and more.
order: 210
---

# HTTP routes

---

## Overview

**HTTP routes** are the most basic **endpoints** you can create in Mockoon. They are flexible and can be used to mock any type of API. They support many customizations like [headers](docs:response-configuration/response-headers) and [body](docs:response-configuration/response-body) and can have [multiple responses](docs:route-responses/multiple-responses) and [rules](docs:route-responses/dynamic-rules) to handle different scenarios.

To create a new HTTP route, click on the "HTTP route" entry in the add route menu:

![Add a new HTTP route{498x304}](docs-img:add-http-route.png)

A new route will be created with a default 200 status code and an empty body. You can then customize it to fit your needs.

![view of a new HTTP route{1484x476}](docs-img:new-http-route.png)

## Independence and statelessness

All HTTP routes are **independent** of each other and **stateless**. It means that HTTP routes will **not share any data** with other routes and that the route will **not remember any information** between requests. This is important to keep in mind when creating complex APIs with multiple routes.

Some exceptions to this rule are:

- [**Global variables**](docs:variables/global-variables) that can be used to store and share data between routes in the templating engine.
- [**Rules based on the request number**](docs:route-responses/dynamic-rules#1-target) that can be used to answer differently based on the index of the requests.
- [**Data buckets**](docs:data-buckets/overview) that can be used to serve data from a shared source. However, the data bucket cannot be modified by an HTTP route, see below.

## Relation with data buckets

HTTP routes can use [**data buckets**](docs:data-buckets/overview) to serve data from a **shared source** and avoid duplication. By selecting ["Data bucket" in the route response body type](docs:response-configuration/response-body#data-bucket), you can choose a data bucket to serve data from for any of your routes.

However, the **data bucket cannot be modified** by an HTTP route. Example: an HTTP route with a PUT method won't be able to update a data bucket. It ensures that the data bucket remains a shared source of truth and that the HTTP routes remain stateless.

If you want a data bucket to act as a **simple JSON database** and be **manipulated** by your endpoints, you can create [**CRUD routes**](docs:api-endpoints/crud-routes) that will be able to interact with the data bucket by creating, reading, filtering, updating, and deleting data, in a RESTful way.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/docs/latest/callbacks/overview/add-callback.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 04b347a

Please sign in to comment.