client

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package client defines types and functions for interacting with docconv HTTP servers.

Index

Constants

View Source
const DefaultEndpoint = "localhost:8888"

DefaultEndpoint is the default endpoint address (host:port) for docconv HTTP servers.

View Source
const DefaultProtocol = "http://"

DefaultProtocol is the default protocol used to construct paths when making docconv requests.

Variables

View Source
var DefaultHTTPClient = http.DefaultClient

DefaultHTTPClient is the default HTTP client used to make requests to docconv HTTP servers.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a docconv HTTP client. Use New to make new Clients.

func New

func New(opts ...Opt) *Client

New creates a new docconv client for interacting with a docconv HTTP server.

func (*Client) Convert

func (c *Client) Convert(r io.Reader, filename string) (*Response, error)

Convert a file from a local path using the http client

type Opt

type Opt func(*Client)

Opt is an option used in New to create Clients.

func WithEndpoint

func WithEndpoint(endpoint string) Opt

WithEndpoint set the endpoint on a Client.

func WithHTTPClient

func WithHTTPClient(client *http.Client) Opt

WithHTTPClient sets the *http.Client used for all underlying calls.

func WithProtocol

func WithProtocol(protocol string) Opt

WithProtocol sets the protocol used in HTTP requests. Currently this must be either http:// or https://.

type Response

type Response struct {
	Body  string            `json:"body"`
	Meta  map[string]string `json:"meta"`
	MSecs uint32            `json:"msecs"`
	Error string            `json:"error"`
}

Response is from docconv.Response copied here to avoid dependency on the docconv package.

func ConvertPath

func ConvertPath(c *Client, path string) (*Response, error)

ConvertPath uses the docconv Client to convert the local file found at path.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL