web

package
v0.0.0-...-2e7332a Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2019 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Logging

func Logging(next http.Handler, log *logrus.Logger) http.Handler

Logging logs http requests

func SingleFile

func SingleFile(filename string) http.Handler

SingleFile returns a handler

Types

type Config

type Config struct {
	Port  int
	URL   string
	Admin string
	Log   struct {
		File  string
		Level string
	}
	SSL struct {
		Key         string
		Certificate string
	}
	Jwt struct {
		Key string
	}
}

Config of a web server

func GetConfig

func GetConfig(source interface{}, environment string) (server Config, err error)

GetConfig returns a Server configurations

type IServer

type IServer interface {
	Start() error
	Stop()
}

IServer is an http.ServeMux with a Context.

type LoggingServeMux

type LoggingServeMux struct {
	// contains filtered or unexported fields
}

LoggingServeMux logs HTTP requests

func NewLoggingServeMux

func NewLoggingServeMux(conf Config) *LoggingServeMux

NewLoggingServeMux allocates and returns a new LoggingServeMux

func (*LoggingServeMux) Handle

func (mux *LoggingServeMux) Handle(pattern string, handler http.Handler)

Handle register handler

func (*LoggingServeMux) HandleFunc

func (mux *LoggingServeMux) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))

HandleFunc registers the handler function for the given pattern.

func (*LoggingServeMux) Handler

func (mux *LoggingServeMux) Handler(r *http.Request) (h http.Handler, pattern string)

Handler sastisfy interface

func (*LoggingServeMux) ServeHTTP

func (mux *LoggingServeMux) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP

type Server

type Server struct {
	http.Server
	Config Config
	Error  chan error
	Done   chan bool
	// contains filtered or unexported fields
}

Server is a Server with a specialize Context.

func NewServer

func NewServer(filename string, environment string) (server *Server, err error)

NewServer create a new instance of Server

func (*Server) Start

func (s *Server) Start() (err error)

Start the server.

func (*Server) Stop

func (s *Server) Stop()

Stop the server.

type ServerEnvironment

type ServerEnvironment struct {
	Env map[string]Config
}

ServerEnvironment configurations

func (*ServerEnvironment) GetEnvironment

func (se *ServerEnvironment) GetEnvironment(environment string) interface{}

GetEnvironment returns a Server configuration for the specified environment in parameter

func (*ServerEnvironment) UnmarshalYAML

func (se *ServerEnvironment) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements Unmarshaler. Avoid use of env in the YAML file.

type StatusResponseWriter

type StatusResponseWriter struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

StatusResponseWriter returns status code

func (*StatusResponseWriter) Header

func (w *StatusResponseWriter) Header() http.Header

Header Satisfy the http.ResponseWriter interface

func (*StatusResponseWriter) Hijack

Hijack Satisfy the http.ResponseWriter interface

func (*StatusResponseWriter) Length

func (w *StatusResponseWriter) Length() int

Length return response size

func (*StatusResponseWriter) Status

func (w *StatusResponseWriter) Status() int

Status return status code

func (*StatusResponseWriter) Write

func (w *StatusResponseWriter) Write(data []byte) (int, error)

Write Satisfy the http.ResponseWriter interface

func (*StatusResponseWriter) WriteHeader

func (w *StatusResponseWriter) WriteHeader(statusCode int)

WriteHeader writes status code

Jump to

Keyboard shortcuts

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