Documentation ¶
Index ¶
- Constants
- Variables
- func Boot(t *transport.HTTP, handler *H, finished chan struct{}) (chan struct{}, error)
- func CORS(ctx *gin.Context)
- func TransformSwaggerRoute(route string) string
- type H
- func (h *H) CreateClients() error
- func (h *H) CreateRouter() (*gin.Engine, error)
- func (h *H) CreateTransport() (*transport.HTTP, error)
- func (h *H) GetClient(ctx *gin.Context) (github.Client, error)
- func (h *H) GetGithub(ctx *gin.Context) (u *model.User, outErr error)
- func (h *H) GetUser(ctx *gin.Context) (*model.User, error)
- func (h *H) GithubClient(token *types.OAuthToken) github.Client
- func (h *H) Init() error
- func (h *H) LogError(err error, ctx *gin.Context, code int)
- func (h *H) NewTracingSpan(ctx *gin.Context, operation string) opentracing.Span
- func (h *H) OAuthRedirect(ctx *gin.Context, scopes []string) error
- func (h *H) Session(ctx *gin.Context) sessions.Session
- func (h *H) WriteError(ctx *gin.Context, err error)
- type HandlerConfig
- type HandlerFunc
- type Route
- type Routes
- type WebsocketFunc
Constants ¶
const SessionUsername = "username"
SessionUsername is the name of the session key that contains our username value.
Variables ¶
var AllowOrigin = "*"
AllowOrigin changes the scope of CORS requests. By default they are insecure; this is intended to be overrided by commands as they set up this library along with their other standard init operations.
var ErrRedirect = errors.New("redirection")
ErrRedirect indicates that the error intends to redirect the user to the proper spot.
Functions ¶
func Boot ¶
Boot boots the service. Closing the channel returned will shutdown the service. At shutdown time, this routine will close the finished channel when it is finished shutting everything down, so the program can safely terminate.
func CORS ¶
CORS primes OPTIONS and normal requests with the appropriate headers and also acts like a normal http.Handler so it can be used that way.
func TransformSwaggerRoute ¶
TransformSwaggerRoute merely translates url params from {thisformat} to :thisformat
Types ¶
type H ¶
type H struct { Config HandlerConfig `yaml:"-"` Routes Routes `yaml:"-"` config.UserConfig `yaml:",inline"` config.Service }
H is a series of HTTP handlers for the UI service
func (*H) CreateClients ¶
CreateClients creates the clients to be used based on configuration values.
func (*H) CreateRouter ¶
CreateRouter creates a *mux.Router capable of serving the UI server.
func (*H) CreateTransport ¶
CreateTransport creates a transport with optional certification information.
func (*H) GetClient ¶
GetClient returns a github client that works with the credentials in the given context.
func (*H) GithubClient ¶
func (h *H) GithubClient(token *types.OAuthToken) github.Client
GithubClient is a wrapper for config.GithubClient.
func (*H) NewTracingSpan ¶
NewTracingSpan creates a new tracepoint span for opentracing instrumentation.
func (*H) OAuthRedirect ¶
OAuthRedirect redirects the user to the OAuth redirection URL.
func (*H) WriteError ¶
WriteError standardizes the writing of error states for easier typing. It is not intended to be used to write specific statuses, only 500 errors with JSON output. If UseSessions is on, it will populate the errors session store.
type HandlerConfig ¶
type HandlerConfig interface { SetRoutes(*H) DBConfigure(*H) error Configure(Routes) error CustomInit(*H) error Validate(*H) error }
HandlerConfig provides an interface to managing the HandlerConfig.
type HandlerFunc ¶
HandlerFunc is the basic kind of HandlerFunc.
type Route ¶
type Route struct { Method string UseCORS bool UseAuth bool WebsocketProcessor WebsocketFunc Handler func(*H, *gin.Context, HandlerFunc) error Processor HandlerFunc ParamValidator func(*H, *gin.Context) error Capability model.Capability TokenScope string }
Route is a route management struct for generated services.
type Routes ¶
Routes is a collection of Route structs.
func (Routes) SetProcessor ¶
func (r Routes) SetProcessor(route string, method string, processor HandlerFunc)
SetProcessor allows you to more simply set the processor for a given route.
func (Routes) SetWebsocketProcessor ¶
func (r Routes) SetWebsocketProcessor(route string, processor WebsocketFunc)
SetWebsocketProcessor allows you to more simply set the processor for a given route.