Checkpoint is where you will be able to intercept, inspect, and modify requests or responses in Marasi. Like Compass, it is an extension and can be configured in Lua.

To get started, open the top accordion or press ⌘/Ctrl+P. This editor is where you will be configuring your interception rules.

Default Checkpoint View

Interception Rules

Checkpoint will run interceptRequest and interceptResponse, if these functions return true, the item will be added to the interception queue.

For example, the below function will intercept any request that has a URL matching https://marasi.app.

function interceptRequest(request)
  return request:url():string() == "https://marasi.app/"
end

Intercepted Item

Once a request/response is in the queue you will be given the option to drop or forward it through Marasi.

Any modification made to the item will need to be valid HTTP. Other fields such as the Content-Length will update automatically once the item is forwarded.

Working with Intercepted Items

Every time an item is intercepted it is added to the queue. The number of items in the queue is displayed above the intercepted item editor. You have three options to choose from:

  1. Drop the item, meaning it will not reach the client or server.
  2. Forward the item with or without modification.
  3. Forward the item with or without modification and intercept the incoming response.

Common Interceptions

Intercept only POST requests

function interceptRequest(request)
  return request:method() == "POST"
end

Intercept requests with ‘oauth’ in the URL

function interceptRequest(request)
  return marasi.strings:contains(request:url():string(), "oauth")
end

Intercept responses with a specific metadata field set

When processing an outbound request, you may set a metadata key if certain conditions are met. This metadata value persists in the response and can be used to build interception logic.

-- Setting the metadata key in the Workshop
function processRequest(req)
  req:set_metadata({test_key = "Hello"})
end

-- Checkpoint Code
function interceptResponse(response)
  return response:metadata()["workshop"] and response:metadata()["workshop"]["test_key"]
end

You can play around with the Checkpoint feature to meet your needs. Next up, we will be going over Launchpad where you will be able to rapidly iterate and modify requests.