handlers

package
v0.0.0-...-9af805d Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2016 License: GPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(ctx context.Context, w http.ResponseWriter, r *http.Request)

Types

type EndpointsInfo

type EndpointsInfo struct {
	Endpoints []HandlerInfo
}
var Endpoints *EndpointsInfo = &EndpointsInfo{
	Endpoints: []HandlerInfo{
		{
			Regexp: regexp.MustCompile("^" + api.TopicsPath + "/(?P<topic>[A-Za-z0-9_-]+)/(?P<partition>[0-9]+)/?$"),
			Handlers: MethodHandlers{
				"GET":  topicGetHandler,
				"POST": jsonresponse.Handler(topicPostHandler),
			},
		},
		{
			Regexp: regexp.MustCompile("^" + api.InfoTopicsPath + "/(?P<topic>[A-Za-z0-9_-]+)/(?P<partition>[0-9]+)/?$"),
			Handlers: MethodHandlers{
				"GET": jsonresponse.Handler(infoSinglePartitionHandler),
			},
		},
		{
			Regexp: regexp.MustCompile("^" + api.InfoTopicsPath + "/(?P<topic>[A-Za-z0-9_-]+)/?$"),
			Handlers: MethodHandlers{
				"GET": jsonresponse.Handler(infoAllPartitionHandler),
			},
		},
		{
			Regexp: regexp.MustCompile("^" + api.InfoTopicsPath + "/?$"),
			Handlers: MethodHandlers{
				"GET": jsonresponse.Handler(infoTopicsHandler),
			},
		},
		{
			Regexp: regexp.MustCompile("^" + api.BlobsPath + "/(?P<digest>[a-zA-Z0-9]+:[a-zA-Z0-9]+)/?$"),
			Handlers: MethodHandlers{
				"GET": blobGetHandler,
			},
		},
		{
			Regexp: regexp.MustCompile("^" + api.JSONTopicsPath + "/(?P<topic>[A-Za-z0-9_-]+)/(?P<partition>[0-9]+)/?$"),
			Handlers: MethodHandlers{
				"GET":  jsonresponse.Handler(jsonGetHandler),
				"POST": jsonresponse.Handler(jsonPostHandler),
			},
		},
		{
			Regexp: regexp.MustCompile("^" + api.PingPath + "$"),
			Handlers: MethodHandlers{
				"GET": pingHandler,
			},
		},
		{
			Regexp: regexp.MustCompile("^" + api.EtcdMembersPath + "/(?P<memberid>[0-9]+)/?$"),
			Handlers: MethodHandlers{
				"POST":   jsonresponse.Handler(etcdUpdateHandler),
				"DELETE": jsonresponse.Handler(etcdDeleteHandler),
			},
		},
		{
			Regexp: regexp.MustCompile("^" + api.EtcdMembersPath + "$"),
			Handlers: MethodHandlers{
				"GET":  jsonresponse.Handler(etcdListHandler),
				"POST": jsonresponse.Handler(etcdAddHandler),
			},
		},
		{
			Regexp: regexp.MustCompile("^/"),
			Handlers: MethodHandlers{
				"GET": defultHandler,
			},
		},
	},
}

type HandlerInfo

type HandlerInfo struct {
	Regexp   *regexp.Regexp
	Handlers MethodHandlers
}

type MethodHandlers

type MethodHandlers map[string]webapi.Handler

Jump to

Keyboard shortcuts

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