rest

package module
v0.0.0-...-7b560b6 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

README

rest

Raiqub/rest is a library for the Go Programming Language. It provides a RESTful router for APIs.

Status

Build Status Coverage GoDoc

Installation

To install raiqub/rest library run the following command:

go get github.com/raiqub/rest

Documentation

Overview

Package rest provides operations to implement a RESTful API.

Route

A Route provides a easy way to define HTTP routes and handle it.

Rest

A Rest provides an URL router for a RESTful API.

Route

A Route provides a easy way to define HTTP routes and handle it.

Index

Constants

This section is empty.

Variables

View Source
var (
	CloudflareRanges = []string{
		"https://www.cloudflare.com/ips-v4",
		"https://www.cloudflare.com/ips-v6",
	}
)

Functions

func RecoverHandlerJson

func RecoverHandlerJson(c *gin.Context)

RecoverHandlerJson is a HTTP request middleware that captures panic errors and returns it as HTTP JSON response.

Types

type RateLimiter

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

A RateLimiter limits the number of requests per timing window.

func NewRateLimiter

func NewRateLimiter(store data.Store, threshold int) *RateLimiter

NewRateLimiter creates a new instance of RateLimiter based on specified store and number of requests per timing window.

func (*RateLimiter) AddCall

func (lmt *RateLimiter) AddCall(id string) int

AddCall register a new request for specified identifier and returns how many levels the identifier overflow the threshold.

func (*RateLimiter) Stack

func (lmt *RateLimiter) Stack(another *RateLimiter)

Stack sets a rate limiter for the next level.

type RouteVars

type RouteVars map[string]string

A RouteVars represents the route variables for specified request.

func (RouteVars) GetInt

func (s RouteVars) GetInt(key string) (int, bool)

GetObjectId tries to gets the value for specified key as int.

func (RouteVars) GetObjectId

func (s RouteVars) GetObjectId(key string) (bson.ObjectId, bool)

GetObjectId tries to gets the value for specified key as BSON ObjectId.

func (RouteVars) GetString

func (s RouteVars) GetString(key string) (string, bool)

GetObjectId tries to gets the value for specified key as string.

type Whitelist

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

func NewWhitelist

func NewWhitelist(interval time.Duration, urls []string) *Whitelist

func (*Whitelist) Handler

func (w *Whitelist) Handler(c *gin.Context)

Jump to

Keyboard shortcuts

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