http

package
v0.0.1-0...-a0864a0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2019 License: MIT Imports: 15 Imported by: 0

README

HTTP input plugin

Description

This plugin starts a webserver and accepts requests based on the config file.

Requirements
  • A server exposed to the clients requesting.
  • A Port to run on.
  • Cert and Key files in case of https
Usage

This is an example of http config:

port: 80                                                        (required)
form_name: image                                                (required)
paths:                                                          (required)
    "/profile_picture":
        pipeline: "@{pipeline}"
    "/cover_picture/":
        pipeline: "@{pipeline}"
Ratelimit: 5                                                    (optional)

Http Plugin Configuration Options

This plugin supports the following configuration options.

Setting Input type Required Dynamic
port integer yes no
form_name string yes no
certFile string no no
keyFile string no no
paths string no no
logrequest integer no no
logresponse integer no no
ratelimit float64 no no
port
  • This is a required setting
  • Value type is integer
  • There is no default value for this setting.
form_name
  • This is a required setting
  • Value type is string
  • There is no default value for this setting.
https_config
  • This is an optional setting, but should be set in order to have https.
  • Value type is string which is the directory for key file.
  • There is no default value for this setting.
paths
  • At least 1 path has to be set.
  • Every set path should be string and has an inside value which is a pipeline which is dynamic.
  • There is no default value for this setting.
logrequest
  • Value type is integer

  • Can take one of 3 values

    0: No requests shall be logged.

    1: All requests shall be logged by Debug logger.

    2: All requests shall be logged by Info logger.

logresponse
  • Value type is integer

  • Can take one of 3 values

    0: Nothing shall be logged.

    1: All successful requests shall be logged.

    2: All Failed requests shall be logged with their errors.

ratelimit
  • Value type is Float64.
  • If not set or set by 0, no rate limit.
  • The number set is the number of maximum requests per second.

Documentation

Index

Constants

View Source
const (
	LogDebug = iota
	LogInfo
)

ENUM for logging requests LFail: Log all requests via logger debug LogInfo: Log all requests via logger info

Variables

This section is empty.

Functions

func NewComponent

func NewComponent() component.Base

NewComponent returns a new component of type HTTP plugin.

Types

type Webserver

type Webserver struct {
	Server *http.Server
	// contains filtered or unexported fields
}

Webserver take input from HTTP requests

func (*Webserver) Init

func (w *Webserver) Init(config cfg.Config, logger zap.SugaredLogger) error

Init initializes the web-server and read its config

func (*Webserver) JobChan

func (w *Webserver) JobChan() <-chan job.Input

JobChan return job channel used to send jobs on.

func (*Webserver) Start

func (w *Webserver) Start() error

Start : starts the server and serve requests

func (*Webserver) Stop

func (w *Webserver) Stop() error

Stop : graceful shutdown.

Jump to

Keyboard shortcuts

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