HTTP Style and Syntax

http.Join(arrows ...http.Arrow) assay.Arrow

builds higher-order HTTP closure, so called assay.Arrow, from primitive elements.


Let’s look on these primitives:

  1. HTTP Style and Syntax
    1. Imports
    2. Writer
      1. Method & URL
      2. Query Params
      3. Headers
      4. Request payload
    3. Reader
      1. Status Code
      2. Headers
      3. Response payload


Any suite requires at least these three modules:

import (
  ƒ ""
  ø ""


Writer morphism (Symbol ø) focuses inside and reshapes HTTP protocol request. The writer morphism is used to declare HTTP method, destination URL, request headers and payload.

Method & URL

Like any HTTP request, you have to define method and destination URL:

// built-in method

// generic variant 
ø.URL("PATCH", "")

These functions are able to format URL according to standard specifiers.

ø.GET("", "test", 10)

lit := "test"
ø.GET("", lit)
ø.GET("", &lit)

Important Formatted values are escaped using percent encoding.

// this ok
ø.GET("https://%s/%s", "", "test")

// this do not work
ø.GET("https://%s", "")

Query Params

It is possible to use inline query parameters but it is not a type safe approach:

ø.GET("", "test")

The SDK implement an arrow ø.Params. It takes a struct serializes it to string and appends query params. You are able to define proper types for your api:

type MyParam struct {
  Site string `json:"site,omitempty"`
  Host string `json:"host,omitempty"`

ø.Params(MyParam{Site: "site", Host: "host"})


Headers are optional, you define as many headers as needed either using string literals or state variables.

// the literal value is defined using Is 

// the header value is defined from state variable

Important There are header constants for frequently used headers.

Request payload

ø.Send transmits the payload to destination URL. The function takes Go data types (e.g. maps, struct, etc) and encodes its to binary using Content-Type as a hint. The function fails if content type is not supported by the library.

type MyType struct {
  Site string `json:"site,omitempty"`
  Host string `json:"host,omitempty"`

ø.Send(MyType{Site: "site", Host: "host"})
  "site": "site",
  "host": "host",

Only following content types supported:

  • application/json
  • application/x-www-form-urlencoded


Reader morphism (Symbol ƒ) focuses into side-effect, HTTP protocol response. The reader morphism is a pattern matcher, is used to match HTTP response code, headers and response payload.

Status Code

Each quality assessment have to declare expected status code(s). The primitive ƒ.Code takes one or few HTTP Status Codes. The assessment fails if microservice responds with other status.



It is possible to match value of HTTP header in the response. The assessment fails if response is missing header or its value do not matches desired one:

// matches Content-Type value 

// matches any value of Content-Type header

The assessment statements can lifts the header value to the variable.

var content string

Response payload

ƒ.Recv decodes the response payload to Golang native data structure using Content-Type header as a hint.

type MyType struct {
  Site string `json:"site,omitempty"`
  Host string `json:"host,omitempty"`

var data MyType

The codec only supports:

  • application/json
  • application/x-www-form-urlencoded

It is possible to bypass auto-codec and receive raw binary data

var data []byte

Copyright © 2019 - 2020 Confirm Quality, Eliminate Risks with Assay It