#http-request #automation #processor #automaat #request-headers #header #request-body

automaat-processor-http-request

HTTP Request processor for the Automaat automation utility

1 unstable release

0.1.0 Jun 23, 2019

#7 in #automaat

MIT/Apache

26KB
349 lines

Automaat Processor: Redis Command

🚧 Work In Progress 🚧


lib.rs:

An Automaat processor to execute HTTP requests.

This processor allows you to make simple HTTP requests. It supports request headers, setting a request body, and asserting the response status.

If more power or functionality is needed, we can add it as needed. However, you can always use the Shell Command processor combined with a utility like cURL if you need more advanced functionality.

Examples

GET

A GET request with headers attached.

use automaat_core::{Context, Processor};
use automaat_processor_http_request::{HttpRequest, Method, Header};
use url::Url;

let context = Context::new()?;
let url = Url::parse("https://httpbin.org/headers")?;
let headers = vec![
    Header::new("accept", "application/json"),
    Header::new("content-type", "text/html"),
];

let processor = HttpRequest {
    url: url,
    method: Method::GET,
    headers: headers,
    body: None,
    assert_status: vec![],
};

let output = processor.run(&context)?;

POST

Simple POST request with a query parameter and a body.

use automaat_core::{Context, Processor};
use automaat_processor_http_request::{Method, HttpRequest };
use url::Url;

let context = Context::new()?;
let url = Url::parse("https://httpbin.org/response-headers?hello=world")?;

let processor = HttpRequest {
    url: url,
    method: Method::POST,
    headers: vec![],
    body: Some("universe".to_owned()),
    assert_status: vec![200],
};

let output = processor.run(&context)?;

Package Features

  • juniper – creates a set of objects to be used in GraphQL-based requests/responses.

Dependencies

~21–34MB
~586K SLoC