app

package
v0.0.0-...-e8b5f56 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2015 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HeadersFromBackend = []string{"Content-Type", "Etag", "Last-Modified"}
	HeadersFromClient  = []string{"Content-Type", "If-None-Match", "If-Modified-Since"}
)

Functions

This section is empty.

Types

type ApiHandler

type ApiHandler func(r *http.Request) (httpCode int, result interface{})

type App

type App struct {
	*Conf
	DB              *sql.DB
	Router          *mux.Router
	Log             *logrus.Logger
	LocalAuthTokens *codereg.Reg
	OAuthCodes      *codereg.Reg
}

func (*App) ApiCall

func (a *App) ApiCall(ah ApiHandler) http.HandlerFunc

func (*App) AppsDelete

func (a *App) AppsDelete(r *http.Request) (int, interface{})

Удаление приложения

func (*App) AppsInfo

func (a *App) AppsInfo(r *http.Request) (int, interface{})

Публичная информация о приложении, доступна без авторизации

func (*App) AppsList

func (a *App) AppsList(r *http.Request) (int, interface{})

Список собственных приложений данного юзера

func (*App) AppsNew

func (a *App) AppsNew(r *http.Request) (int, interface{})

Создание нового приложения

func (*App) AppsUpdate

func (a *App) AppsUpdate(r *http.Request) (int, interface{})

Изменение приложения

func (*App) AuthInit

func (app *App) AuthInit(r *http.Request) (int, interface{})

Начальная авторизация Получаем {username:…, password:…}, отдаём token

func (*App) AuthRefresh

func (app *App) AuthRefresh(r *http.Request) (int, interface{})

Обновление авторизации Ничего не получаем, ориентируемся на заголовок, отдаём новый token

func (*App) InitRouter

func (app *App) InitRouter()

func (*App) LoadConfig

func (a *App) LoadConfig(file string) error

func (*App) LocalAuthRequired

func (a *App) LocalAuthRequired(h ApiHandler) ApiHandler

func (*App) OAuthNewCode

func (a *App) OAuthNewCode(r *http.Request) (int, interface{})

Выдать код авторизации принимает данные в формате: {"app_key": "…", "redirect_uri": "…", "perms": ["…", …]}

func (*App) OAuthToken

func (a *App) OAuthToken(w http.ResponseWriter, r *http.Request)

Выдача токена по авторизационному коду Ожидает POST-поля: "code", "client_id", "client_secret", "grant_type" = "authorization_code", "redirect_uri"

func (*App) ProxyBackend

func (a *App) ProxyBackend(w http.ResponseWriter, r *http.Request)

func (*App) TokensDelete

func (a *App) TokensDelete(r *http.Request) (int, interface{})

Удаление токена

func (*App) TokensList

func (a *App) TokensList(r *http.Request) (int, interface{})

Список активных токенов данного юзера

type Conf

type Conf struct {
	Listen            string
	Secret            []byte
	DBUrl             string
	LogLevel          string
	CORSOrigins       []string
	BackendAPIRoot    string
	BackendAPIMethods map[string]string
}

type H

type H map[string]interface{}

type OAuthCodeInfo

type OAuthCodeInfo struct {
	AppID       int
	UserID      int
	RedirectURI string
	Perms       []string
}

type OwnApp

type OwnApp struct {
	Key         string           `json:"key"`
	Secret      string           `json:"secret,omitempty"`
	Date        time.Time        `json:"date,omitempty"`
	Title       string           `json:"title"`
	Description string           `json:"description"`
	Domains     sqlt.StringSlice `json:"domains"`
}

type TokenInfo

type TokenInfo struct {
	ID    int               `json:"id"`
	Date  time.Time         `json:"date"`
	Perms map[string]string `json:"perms"`
	App   struct {
		Title       string           `json:"title"`
		Description string           `json:"description"`
		Owner       string           `json:"owner"`
		Domains     sqlt.StringSlice `json:"domains"`
	} `json:"app"`
}

Jump to

Keyboard shortcuts

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