Skip to main content

Overview

The network section validates connectivity to external services and APIs. This ensures that required network endpoints are accessible before running your application.

Configuration

Each network check is defined by a NetworkCheck struct (src/config.rs:51) with the following fields:
string
required
The URL to check. Must be a valid HTTP or HTTPS URL.
number
Expected HTTP status code. If specified, the check fails if the response status doesn’t match. If omitted, any successful response (2xx or 3xx) is accepted.

Examples

Basic Connectivity Check

Check that a URL is accessible:

Status Code Validation

Verify specific HTTP status codes:

Multiple Endpoints

Check connectivity to multiple services:

Real-World Examples

Use Cases

External API Availability

Verify that third-party services are accessible:

Local Services

Check that required local services are running:

Health Checks

Verify application health endpoints:

Package Registries

Ensure package registries are accessible:

Status Code Behavior

When status_code is Specified

The check succeeds only if the response status matches exactly:

When status_code is Omitted

The check succeeds for any successful HTTP response (2xx or 3xx status codes):
From src/config.rs:54, the status_code field defaults to None, meaning any successful response is accepted.

Common Status Codes

Protocol Support

Network checks support:
  • HTTP: http://example.com
  • HTTPS: https://example.com
  • Localhost: http://localhost:3000
  • IP addresses: http://192.168.1.100:8080
  • Custom ports: http://example.com:8080

Default Behavior

From the struct definition in src/config.rs:51:
  • url: Required field, no default
  • status_code: Defaults to None (accepts any 2xx/3xx response)
Network checks will fail if:
  • The URL is unreachable (network error, DNS failure, timeout)
  • The response status code doesn’t match status_code (when specified)
  • The URL is malformed or uses an unsupported protocol
Use network checks sparingly in local development to avoid slow validation times. Consider using them primarily for critical external dependencies or in CI/CD environments where network reliability matters more.

Combining with Other Checks

Network checks work well with other validation types: