unet

package
v0.0.0-...-76c535a Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2021 License: MIT Imports: 7 Imported by: 0

README

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.

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 HostName

func HostName() (hostName string)

Returns the result of `os.Hostname` if any, else `localhost`.

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