kipp

package module
v0.2.2-0...-86e9763 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2023 License: GPL-3.0 Imports: 25 Imported by: 0

README

kipp

Go Reference Go Report Card

Getting started

The easiest way to get started with kipp is by using the image published to Docker Hub. The service is then available simply by running:

docker pull uhthomas/kipp
docker run uhthomas/kipp

Databases

Databases can be configured using the --database flag. The flag requires the input be parsable as a URL. See the url.Parse docs for more info.

Badger

Badger is a fast, embedded database which is great for single instances.

SQL

Kipp uses a generic SQL driver, but currently only loads:

As long as a database supports Go's sql package, it can be used. Please file an issue for requests.

File systems

File systems can be configured using the --filesystem flag. The flag requires the input be parsable as a URL. See the url.Parse docs for more info.

Local (your local file system)

The local filesystem does not require any special formatting, and can be used like a regular path such

--filesystem /path/to/files
AWS S3

AWS S3 requires the s3 scheme, and has the following syntax:

--filesystem s3://some-token:some-secret@some-region/some-bucket?endpoint=some-endpoint.

The region and bucket are required.

The user info section is optional, if present, will create new static credentials. Otherwise, the default AWS SDK credentials will be used.

The endpoint is optional, and will use the default AWS endpoint if not present. This is useful for using S3-compatible services such as:

Policy

Required actions:

  • s3:DeleteObject
  • s3:GetObject
  • s3:PutObject

This is subject to change in future as more features are added.

Building from source

Kipp builds, tests and compiles using Bazel. To run/build locally with bazel:

git clone git@github.com:uhthomas/kipp
cd kipp
bazel run //cmd/kipp

API

Kipp has two main components; uploading files and downloading files. Files can be uploaded by POSTing a multipart form to the / endpoint like so:

curl https://kipp.6f.io -F file="some content"

The service will then respond with a 302 (See Other) status and the location of the file. It will also write the location to the response body.

Kipp also serves all files located in the web directory by default, but can either be disabled or changed to a different location.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(ctx context.Context, s *Server) error

func DB

func DB(db database.Database) Option

func Data

func Data(path string) Option

func FS

func Lifetime

func Lifetime(d time.Duration) Option

func Limit

func Limit(n int64) Option

func ParseDB

func ParseDB(ss string) Option

func ParseFS

func ParseFS(ss string) Option

type Server

type Server struct {
	Database   database.Database
	FileSystem filesystem.FileSystem
	Lifetime   time.Duration
	Limit      int64
	PublicPath string
	// contains filtered or unexported fields
}

Server acts as the HTTP server and configuration.

func New

func New(ctx context.Context, opts ...Option) (*Server, error)

func (Server) Health

func (s Server) Health(w http.ResponseWriter, r *http.Request)

func (Server) ServeHTTP

func (s Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP will serve HTTP requests. It first tries to determine if the request is for uploading, it then tries to serve static files and then will try to serve public files.

func (Server) UploadHandler

func (s Server) UploadHandler(w http.ResponseWriter, r *http.Request)

UploadHandler write the contents of the "file" part to a filesystem.Reader, persists the entry to the database and writes the location of the file to the response.

Directories

Path Synopsis
cmd
sql
s3
internal

Jump to

Keyboard shortcuts

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