web

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2018 License: AGPL-3.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetUserID

func GetUserID(ctx context.Context) (int, error)

GetUserID gets the user ID set by the JWT middleware in the Context

func SetUserID

func SetUserID(ctx context.Context, userID int) context.Context

SetUserID sets the user ID to the context

Types

type Auth

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

Auth is http service to authorize users, it uses oAuth and JWT underneath

func NewAuth

func NewAuth(clientID, clientSecret string, signingKey string) *Auth

NewAuth create new Auth service

func (*Auth) Callback

func (a *Auth) Callback(w http.ResponseWriter, r *http.Request)

Callback makes exchange with oauth provider and redirects to index page with JWT token

func (*Auth) Login

func (a *Auth) Login(w http.ResponseWriter, r *http.Request)

Login handler redirects user to oauth provider

func (*Auth) Middleware

func (a *Auth) Middleware(next http.Handler) http.Handler

Middleware return http.Handler which validates token and set user id in context

type HTTPServer

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

func NewHTTPServer

func NewHTTPServer(auth *Auth, static *Static) *HTTPServer

func (*HTTPServer) ServeHTTP

func (s *HTTPServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Static

type Static struct{}

Static without the 'bindata' tag contains a placeholder handler that returns 'not implemented'

func NewStatic

func NewStatic(dir, serverURL string, footerHTML string) *Static

NewStatic creates new Static

func (*Static) ServeHTTP

func (s *Static) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves any static file from static directory or fallbacks on index.hml

type User

type User struct {
	ID        int    `json:"id"`
	Login     string `json:"login"`
	Username  string `json:"name"`
	AvatarURL string `json:"avatar_url"`
}

User represents the user response returned by provider

Jump to

Keyboard shortcuts

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