용어 - multiplexer

2018. 3. 16. 10:50Language/go lang

반응형



// Mux is a simple HTTP route multiplexer that parses a request path,
// records any URL params, and executes an end handler. It implements
// the http.Handler interface and is friendly with the standard library.
//
// Mux is designed to be fast, minimal and offer a powerful API for building
// modular and composable HTTP services with a large set of handlers. It's
// particularly useful for writing large REST API services that break a handler
// into many smaller parts composed of middlewares and end handlers.


멀티플렉서?

복수의 입력 중에서 1개를 선택해서 출력하는 전환회로. 복수의 입력은 제어신호에 의해 1개의 출력에 시간분할로 이어 바꿔진다. 논리 게이트로 구성되는 조합 논리 회로이다. 멀티플렉서의 역기능 회로를 디멀티플렉서(demultiplexer)라고 한다.

Mux요청경로를 파싱하는 간단한 HTTP route multiplexer이며, URL params을 기록하고 종료 처리기를 실행합니다.

이것은 http.Handler를 구현하며 표준 라이브러리와 친합니다.

Mux는 빠르고 최소한으로 설계되어 modular나 많은 handler를 가지는 http services를 만들기 위해 강력한 api를 제공 합니다.

또한 미들웨어와 엔드 핸들러로 구성된 매우 작은 파트들인 핸들러를 구성하는 rest api service를 만드는데 특히 유용 합니다.

type Mux struct {
// The radix trie router
tree *node

// The middleware stack
middlewares []func(http.Handler) http.Handler

// Controls the behaviour of middleware chain generation when a mux
// is registered as an inline group inside another mux.
inline bool
parent *Mux

// The computed mux handler made of the chained middleware stack and
// the tree router
handler http.Handler

// Routing context pool
pool sync.Pool

// Custom route not found handler
notFoundHandler http.HandlerFunc

// Custom method not allowed handler
methodNotAllowedHandler http.HandlerFunc
}


middleware stack가 뭔지 궁금했는데  []func(http.Handler) http.Handler 였다. 굿굿!


관련하여 chi package를 살펴보자.

2018/03/02 - [Language/go lang] - chi package






반응형

'Language > go lang' 카테고리의 다른 글

http dump  (0) 2018.08.30
golang 채널에 대해 알아보자!  (0) 2018.05.11
golang code 구조 살펴보기  (0) 2018.03.15
golang + github Permanently added the RSA host key  (0) 2018.03.05
golang + github ignore setting  (0) 2018.03.05