Skip to content
This repository has been archived by the owner on Apr 2, 2020. It is now read-only.

Nugine/pastebin-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pastebin-server

Deploy

$ cargo build --release
$ . ./start.sh

JSON API

  • POST /record

    interface Request{
        title: string,
        lang: string,
        content: string,
        expiration: number,
    }
    interface Response{
        key: string
    }
  • GET /record/{key}

    interface Response{
        title: string,
        lang: string,
        content: string,
        saving_time: number,
        expiration: number,
        view_count: number
    }
  • Error

    interface Error{
        code: number,
        message: string
    }

Environment

Prefix: PASTEBIN_

Shared Variable

var default unit description
ADDR localhost:8088 Binding address
CRYPT_KEY magic Crypto key for short url
MAX_POST_SIZE 32768 byte Max length of POST request body

Built-in Memory Store

var default unit description
MAX_STORE_SIZE 104857600 byte An ambiguous size count for controlling server memory usage
MAX_EXPIRATION 604800 second Max expiration time
CLEAN_DURATION 5000 millisecond GC interval

Redis Store

var default unit description
REDIS_URL set PASTEBIN_REDIS_URL to enable redis store

Example

.env

RUST_LOG=info
PASTEBIN_ADDR=localhost:8000
PASTEBIN_CRYPT_KEY=MyImportantSecret
PASTEBIN_REDIS_URL=redis://localhost:6379