lenin

package module
v0.0.0-...-d9f2524 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

README

Repository archiving

This library was archived because a replacement was written for it. Under the MIT license: https://git.lcomrade.su/root/pasteapi.go

Lenin is a golang library for working with the Lenpaste API.

NOTE: Library releases correspond to the Lenpaste server releases.

Install

go get git.lcomrade.su/root/lenin

Example

Create new paste:

package main

import(
	"git.lcomrade.su/root/lenin"
	"fmt"
)

func main() {
	// Base API URL
	baseURL := "https://paste.lcomrade.su/api"

	//Clean base URL
	baseURL = lenin.CleanURL(baseURL)

	// Create request
	req := lenin.NewReq {
		Title: "Lenin library",
		Text: "Lenin is a golang library for working with the Lenpaste API",
		Expiration: "5m",
	}

	// Do request
	resp, err := lenin.New(req, baseURL)
	if err != nil {
		panic(err)
	}

	// Print result
	fmt.Println("Paste name:", resp.Name)
}

Documentation

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanURL

func CleanURL(url string) string

Clean base URL. Performs the following actions:

  1. If the URL does not start with "http://" or "https://" adds "http://".
  2. Deletes the "/" at the end.

Types

type AboutResp

type AboutResp struct {
	Exist bool
	Text  string
}

func About

func About(baseURL string) (AboutResp, error)

Get server about.

type GetResp

type GetResp struct {
	Name string
	Text string
	Info GetRespInfo
}

func Get

func Get(name string, baseURL string) (GetResp, error)

Get existed paste by name.

type GetRespInfo

type GetRespInfo struct {
	CreateTime int64
	DeleteTime int64
	OneUse     bool
	Title      string
}

type NewReq

type NewReq struct {
	Title      string
	Text       string
	OneUse     bool
	Expiration string
}

type NewResp

type NewResp struct {
	Name string
}

func New

func New(req NewReq, baseURL string) (NewResp, error)

Create new paste.

type RulesResp

type RulesResp struct {
	Exist bool
	Text  string
}

func Rules

func Rules(baseURL string) (RulesResp, error)

Get server rules.

type VersionResp

type VersionResp struct {
	Version   string
	GitTag    string
	GitCommit string
	BuildDate string
}

func Version

func Version(baseURL string) (VersionResp, error)

Get server version information.

Jump to

Keyboard shortcuts

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