zerorouter

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

README

zerorouter

2024年の技術書展16で頒布された『ゼロから作るHTTPルーター』のソースコードリポジトリです。

動作環境

Go 1.21.4 or later

リポジトリの内容

chapter2-3

以下の章に対応しています。

  • 2章:トライ木の構築
  • 3章:トライ木の検索 対応するノードの種類によってsimpleparamcatchAllの3種類のバージョンがあります。 フォルダごとに独立して動作可能なプログラムになっています。

chapter4

以下の章に対応しています。

  • 4章:ルーターの構築

Documentation

Overview

Copyright 2024 進捗ゼミ. All rights reserved. Based on the path package, Copyright 2009 The Go Authors. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Copyright 2024 進捗ゼミ. All rights reserved. Based on the path package, Copyright 2009 The Go Authors. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

View Source
var MatchedRoutePathParam = "$matchedRoutePath"
View Source
var ParamsKey = paramsKey{}

Functions

This section is empty.

Types

type Handle

type Handle func(http.ResponseWriter, *http.Request, Params)

type Param

type Param struct {
	Key   string
	Value string
}

type Params

type Params []Param

func ParamsFromContext

func ParamsFromContext(ctx context.Context) Params

func (Params) ByName

func (ps Params) ByName(name string) string

type Router

type Router struct {
	PanicHandler           func(http.ResponseWriter, *http.Request, interface{})
	HandleOPTIONS          bool
	HandleMethodNotAllowed bool
	SaveMatchedRoutePath   bool
	RedirectFixedPath      bool
	// contains filtered or unexported fields
}

func New

func New() *Router

func (*Router) DELETE

func (r *Router) DELETE(path string, handle Handle)

func (*Router) GET

func (r *Router) GET(path string, handle Handle)

func (*Router) HEAD

func (r *Router) HEAD(path string, handle Handle)

func (*Router) Handle

func (r *Router) Handle(method, path string, handle Handle)

func (*Router) Handler

func (r *Router) Handler(method, path string, handler http.Handler)

func (*Router) HandlerFunc

func (r *Router) HandlerFunc(method, path string, handler http.HandlerFunc)

func (*Router) OPTIONS

func (r *Router) OPTIONS(path string, handle Handle)

func (*Router) PATCH

func (r *Router) PATCH(path string, handle Handle)

func (*Router) POST

func (r *Router) POST(path string, handle Handle)

func (*Router) PUT

func (r *Router) PUT(path string, handle Handle)

func (*Router) ServeHTTP

func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)

Directories

Path Synopsis
chapter2-3
chapter6

Jump to

Keyboard shortcuts

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