manael

package module
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2022 License: MIT Imports: 18 Imported by: 0

README

Manael

GoDoc Go Codecov

Manael is a simple HTTP proxy for processing images.

Installation

Usage

$ manael -http=:8080 -upstream_url=http://localhost:9000

License

MIT

Documentation

Overview

Package manael provides HTTP handler for processing images.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode added in v1.8.0

func Decode(r io.Reader) (image.Image, error)

Decode returns an image.Image.

func Encode added in v1.8.0

func Encode(w io.Writer, m image.Image, t string) error

Encode writes the Image m to w in the format specified by Content-Type t.

func NewResponse added in v1.4.4

func NewResponse(r *http.Request, status int) *http.Response

NewResponse returns response

Example
package main

import (
	"fmt"
	"log"
	"net/http"

	"manael.org/x/manael"
)

func main() {
	req, err := http.NewRequest(http.MethodGet, "https://manael.test/", nil)
	if err != nil {
		log.Fatal(err)
	}

	resp := manael.NewResponse(req, http.StatusOK)

	fmt.Println(resp.StatusCode)
}
Output:

200

Types

type Proxy added in v1.4.1

type Proxy struct {
	Transport http.RoundTripper
}

A Proxy responds to an HTTP request.

func NewServeProxy

func NewServeProxy(u string) *Proxy

NewServeProxy returns a new Proxy given a upstream URL

Example
package main

import (
	"log"
	"net/http"

	"manael.org/x/manael"
)

func main() {
	p := manael.NewServeProxy("http://localhost:9000")

	err := http.ListenAndServe(":8080", p)
	if err != nil {
		log.Fatal(err)
	}
}
Output:

func (*Proxy) ServeHTTP added in v1.4.1

func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Transport added in v1.4.1

type Transport struct {
	UpstreamURL string

	Base http.RoundTripper
}

Transport is an http.RoundTripper.

func (*Transport) RoundTrip added in v1.4.1

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip responds to an converted image.

Directories

Path Synopsis
cmd
manael
Manael is a proxy server for processing images.
Manael is a proxy server for processing images.
internal

Jump to

Keyboard shortcuts

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