HTTP

The HTTP protocol implementation could be used to set-up endpoints and service callers. The HTTP protocol implementation supports calls, proxy forwarding and endpoints.

Services

The HTTP protocol could be used inside services to communicate with HTTP services. By default the JSON codec is used but any other available codec inside the Semaphore instance could be used. HTTP services could also be used for proxy forwarding.

users.proto
service User {
    option (maestro.service) = {
        host: "https://service.user/"
        protocol: "http"
        codec: "json"
    };
}

The HTTP server is exposed on the configured port. Check out the Semaphore CLI documentation or the documentation of your own implementation for more information.

$ # Expose a HTTP server on port 8080
$ semaphore run -c config.yaml

Service certificates

Root certificates could be included to provide secure connections. Certificates could be passed as options or be overridden through service selectors.

services {
    select "proto.users.*" {
			host = "api.jexia.com"
			insecure = "false"
			ca_file = "/etc/ca.crt"
    }

    select "proto.projects.*" {
      host = "api.jexia.com"
			insecure = "true"
    }
}

Advanced options

Advanced HTTP options could be configured to have fine grained control over specific values and intervals. The available options are listed below.

service "mock" "http" {
		host = "https://service.prod.svc.cluster.local"

		options {
				flush_interval = "1s"
				timeout = "60s"
				keep_alive = "60s"
				max_idle_conns = "100"
		}
}

Endpoints

Endpoints expose flows. Endpoints could be configured to different methods, accept parameters and return/accept different message content types. URL queries are automatically mapped to the schema and could be used inside the flows.

endpoint "user" "http" {
    method = "GET"
    endpoint = "/user/:id"
    codec = "json"
    read_timeout = "5s"
    write_timeout = "5s"
}

The following options are available inside a endpoint

Key

Description

Default

method

HTTP request method to be used

GET

endpoint

HTTP endpoint path to be called

codec

Message content type to be encoded/decoded

json

Last updated