httpupload

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

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

Go to latest
Published: Apr 14, 2024 License: MIT Imports: 12 Imported by: 0

README

caddy-put-upload

caddy-put-upload is a project that allows you to use HTTP PUT requests for file uploads in the Caddy server.

Using

Pre built binaries

For use with basic authentication or the security module, you can utilize the pre-built binaries available.

  • dist/caddy-put-linux-x86_64 has the caddy standard modules.
  • dist/caddy-put-security-linux-x86_64 has the caddy standard modules and the security module.
Build your own

You can build your own Docker image using the example provided:

FROM caddy:2.7.5-builder AS builder

RUN xcaddy build \
        --with github.com/greenpau/caddy-security@v1.1.19 \
        --with github.com/madworx/caddy-put-upload

FROM caddy:2.7.5

COPY --from=builder /usr/bin/caddy /usr/bin/caddy
Contributing
Easy mode: Use VSCode dev container

You can contribute to this project using the VSCode dev container which provides a pre-configured development environment.

Not using VSCode, but docker

If you're not using VSCode but have Docker installed, you can still contribute by building and running the project using Docker.

$ docker build -t madworx/caddy-put-upload -f .devcontainer/Dockerfile .
$ docker run -it --rm -v $(pwd):/w -w /w madworx/caddy-put-upload make install-deps all
Fully local installation

For a fully local installation, ensure the following prerequisites are installed and in your $PATH:

  • go 1.20+
  • robot framework 6.0+
  • python 3.9+
  • make
  • git

Additional requirements include:

  • Python packages: As listed in e2e_tests/resources/requirements.txt.
  • Golang packages: xcaddy, staticcheck and gofumpt.

For Debian-based installations:

$ sudo apt-get install -y \
    build-essential git \
    python3 python3-pip golang

$ pip3 install -r e2e_tests/resources/requirements.txt
$ go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
$ go install honnef.co/go/tools/cmd/staticcheck@latest

Documentation

Overview

Package httpupload provides a HTTP handler for Caddy server, enabling file uploads using PUT HTTP method.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPUpload

type HTTPUpload struct {
	UploadDir   string `json:"upload_dir,omitempty"`
	RoutePrefix string `json:"route_prefix,omitempty"`
}

HTTPUpload is a struct that defines the module for handling HTTP PUT requests for file uploads.

func (HTTPUpload) CaddyModule

func (HTTPUpload) CaddyModule() caddy.ModuleInfo

CaddyModule provides the module information to Caddy. It creates a new HTTPUpload module.

func (HTTPUpload) Provision

func (h HTTPUpload) Provision(ctx caddy.Context) error

func (HTTPUpload) ServeHTTP

func (h HTTPUpload) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error

ServeHTTP handles the HTTP requests. If it's a PUT request, it handles the upload process and writes the file to the defined upload directory. If the request method is not PUT, it simply calls the next handler in the chain.

func (*HTTPUpload) UnmarshalCaddyfile

func (h *HTTPUpload) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile reads the Caddyfile configuration into the HTTPUpload struct.

Directories

Path Synopsis
cmd
gocovmerge
gocovmerge takes the results from multiple `go test -coverprofile` runs and merges them into one profile
gocovmerge takes the results from multiple `go test -coverprofile` runs and merges them into one profile
e2e_tests

Jump to

Keyboard shortcuts

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