handlers

package
v0.0.0-...-42e8fca Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Page 194 Listing 9-4: The default handler implementation. The handlers.DefaultHandler function returns a function converted to the http.HandlerFunc type. The http.HandlerFunc type implements the http.Handler interface. Go programmers commonly convert a function with the signature func(w http.ResponseWriter, r *http.Request) to the http.HandlerFunc type so the function implements the http.Handler interface.

Pages 198-199 Listing 9-6: Methods map that dynamically routes requests to the right handler.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultHandler

func DefaultHandler() http.Handler

func DefaultMethodsHandler

func DefaultMethodsHandler() http.Handler

Pages 199-200 Listing 9-7: Default implementation of the Methods Handler

Types

type Methods

type Methods map[string]http.Handler

Methods is a map whose key is an HTTP method and whose value is an http.Handler.

func (Methods) ServeHTTP

func (h Methods) ServeHTTP(w http.ResponseWriter, r *http.Request)

It has a ServeHTTP method to implement the http.Handler interface, so you can use Methods as a handler itself.

Jump to

Keyboard shortcuts

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