http

package
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package http provides http client and server implementations.

Package http provides http client and server implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Response

type Response struct {
	Header     http.Header
	Body       string
	StatusCode int
}

Response is response information.

func Request

func Request(url, method string, header map[string][]string, body string, timeout time.Duration, username, password string, transport *http.Transport) (Response, error)

Request is request.

ex) response, err := http.Request("http://127.0.0.1:10000/test/id-01", http.MethodGet, map[string][]string{"header-1": {"value-1"}}, "", 10, "", "", nil)

type Server

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

Server is a struct that provides server related methods.

func (*Server) RegisterHandler added in v1.1.8

func (this *Server) RegisterHandler(path, method string, handler http.Handler)

RegisterHandler is add handler.

ex) server.RegisterHandler("/xxx", http.MethodPost, handler)

func (*Server) RegisterHandlerFunc added in v1.1.6

func (this *Server) RegisterHandlerFunc(path, method string, handlerFunc http.HandlerFunc)

RegisterHandlerFunc is add handler function.

ex) server.RegisterHandlerFunc("/xxx", http.MethodPost, handlerFunc)

func (*Server) RegisterPathPrefixHandler added in v1.1.6

func (this *Server) RegisterPathPrefixHandler(prefix string, handler http.Handler)

RegisterPathPrefixHandler is add path prefix handler.

ex) server.RegisterPathPrefixHandler("xxx", handler)

func (*Server) RegisterPathPrefixHandlerFunc added in v1.1.8

func (this *Server) RegisterPathPrefixHandlerFunc(prefix string, handlerFunc http.HandlerFunc)

RegisterPathPrefixHandlerFunc is add path prefix handler function.

ex) server.RegisterPathPrefixHandlerFunc("xxx", Func)

func (*Server) SetRouter

func (this *Server) SetRouter(router *mux.Router)

SetRouter is set the router.

ex) server.SetRouter(router)

func (*Server) Start

func (this *Server) Start(address string, listenAndServeFailureFunc func(err error), middlewareFunc ...mux.MiddlewareFunc) error

Start is start the server.

ex) err := server.Start(":10000")

func (*Server) Stop

func (this *Server) Stop(shutdownTimeout time.Duration) error

Stop is stop the server.

ex) err := server.Stop(10)

Jump to

Keyboard shortcuts

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