dogbin

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package dogbin provides a simple go client library for dogbin and hastebin.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

type Document struct {
	Slug      string `json:"_id"`
	IsUrl     bool   `json:"isUrl"`
	Content   string `json:"content"`
	ViewCount int    `json:"viewCount"`
}

Document represents the dogbin document structure and is used for both dogbin and hastebin here

type Message

type Message struct {
	Message string `json:"message"`
}

Message represents the json format used by the server for errors

type Server

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

Server defines the dogbin or hastebin server to communicate with

func Dogbin

func Dogbin() Server

Dogbin returns a Server instance configured for the public del.dog dogbin instance

func Hastebin

func Hastebin() Server

Hastebin returns a Server instance configured for the public hastebin.com hastebin instance

func NewServer

func NewServer(server string) Server

NewServer returns a new Server configured for the supplied dogbin/hastebin instance

func (Server) Get

func (d Server) Get(slug string) (*Document, error)

Get gets a *Document from the server for the supplied slug

func (Server) Put

func (d Server) Put(slug string, content string) (*UploadResult, error)

Put uploads content to the server, if a slug is supplied it is assumed that the server supports the extended api used by dogbin.

type UploadRequest

type UploadRequest struct {
	Slug    string `json:"slug"`
	Content string `json:"content"`
}

UploadRequest represents the json used internally for uploads to the dogbin extended API

type UploadResult

type UploadResult struct {
	IsUrl bool   `json:"isUrl"`
	Slug  string `json:"key"`
	Url   string `json:"-"`
}

UploadResult represents the json returned for upload requests

type Wrapper

type Wrapper struct {
	Content  string    `json:"data"`
	Document *Document `json:"document,omitempty"`
	Slug     string    `json:"key"`
}

Wrapper represents the JSON response from hastebin/dogbin which in the case of dogbin simply exists for legacy purposes and wraps around the actual document.

Jump to

Keyboard shortcuts

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