unet

package
v0.0.0-...-2d5b814 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2015 License: BSD-2-Clause Imports: 7 Imported by: 0

README

unet

-- import "github.com/go-utils/unet"

Go programming helpers for common networking needs.

Usage

func Addr
func Addr(protocol, tcpAddr string) (fullAddr string)

Returns a human-readable URL representation of the specified TCP address.

Examples:

unet.Addr("http", ":8080") = http://localhost:8080

unet.Addr("https", "testserver:9090") = https://testserver:9090

unet.Addr("http", ":http") = http://localhost

unet.Addr("https", "demomachine:https") = https://demomachine

func DownloadFile
func DownloadFile(srcFileUrl, dstFilePath string) (err error)

Downloads a remote file at the specified (net/http-compatible) srcFileUrl to the specified dstFilePath.

func OpenRemoteFile
func OpenRemoteFile(srcFileUrl string) (src io.ReadCloser, err error)

Opens a remote file at the specified (net/http-compatible) srcFileUrl and returns its io.ReadCloser.

type ResponseBuffer
type ResponseBuffer struct {
	//	Used to implement the `http.ResponseWriter.Write` method.
	bytes.Buffer

	//	Used to implement the `http.ResponseWriter.Header` method.
	Resp http.Response
}

Implements http.ResponseWriter with a bytes.Buffer.

func (*ResponseBuffer) Header
func (me *ResponseBuffer) Header() http.Header

Returns me.Resp.Header.

func (*ResponseBuffer) WriteHeader
func (_ *ResponseBuffer) WriteHeader(_ int)

No-op -- currently, headers aren't written to the underlying bytes.Buffer.

-- godocdown http://github.com/robertkrimen/godocdown

Documentation

Overview

Go programming helpers for common networking needs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Addr

func Addr(protocol, tcpAddr string) (fullAddr string)

Returns a human-readable URL representation of the specified TCP address.

Examples:

`unet.Addr("http", ":8080")` = `http://localhost:8080`

`unet.Addr("https", "testserver:9090")` = `https://testserver:9090`

`unet.Addr("http", ":http")` = `http://localhost`

`unet.Addr("https", "demomachine:https")` = `https://demomachine`

func DownloadFile

func DownloadFile(srcFileUrl, dstFilePath string) (err error)

Downloads a remote file at the specified (`net/http`-compatible) `srcFileUrl` to the specified `dstFilePath`.

func OpenRemoteFile

func OpenRemoteFile(srcFileUrl string) (src io.ReadCloser, err error)

Opens a remote file at the specified (`net/http`-compatible) `srcFileUrl` and returns its `io.ReadCloser`.

Types

type ResponseBuffer

type ResponseBuffer struct {
	//	Used to implement the `http.ResponseWriter.Write` method.
	bytes.Buffer

	//	Used to implement the `http.ResponseWriter.Header` method.
	Resp http.Response
}

Implements `http.ResponseWriter` with a `bytes.Buffer`.

func (*ResponseBuffer) Header

func (me *ResponseBuffer) Header() http.Header

Returns `me.Resp.Header`.

func (*ResponseBuffer) WriteHeader

func (_ *ResponseBuffer) WriteHeader(_ int)

No-op -- currently, headers aren't written to the underlying `bytes.Buffer`.

Jump to

Keyboard shortcuts

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