Documentation
¶
Overview ¶
APIWS is a package to simplify creation of web servers with static web pages, (typically SPAs) and a REST API.
Index ¶
- func NewBasic(username string, password *string) *basic.Basic
- func NewFile(filePath string) (*file.File, error)
- func NewOIDC(config oidc.OIDCConfig) (*oidc.OIDC, error)
- type APIWS
- func (a *APIWS) AddPublicRoute(pattern string, handler http.Handler, arg ...*RouteOptions)
- func (a *APIWS) AddRoute(pattern string, handler http.Handler, arg ...*RouteOptions)
- func (a *APIWS) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (a *APIWS) Start()
- func (a *APIWS) WithAuthentication(b auth.Authentication) *APIWS
- func (a *APIWS) WithPort(port int) *APIWS
- type RouteOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type APIWS ¶
type APIWS struct {
// contains filtered or unexported fields
}
APIWS is the main structure for the API Web Server.
func New ¶
New creates a new API Web Server. staticUI is the file system containing the web root directory and templateData contains data for templated values present in static web pages.
func (*APIWS) AddPublicRoute ¶
func (a *APIWS) AddPublicRoute(pattern string, handler http.Handler, arg ...*RouteOptions)
AddRoute adds a new route to the API Web Server. The route will not be passed to authentication, handler will be called when pattern matches the request. arg is an optional RouteOptions struct
func (*APIWS) AddRoute ¶
func (a *APIWS) AddRoute(pattern string, handler http.Handler, arg ...*RouteOptions)
AddRoute adds a new route to the API Web Server. handler will be called when pattern matches the request. arg is an optional RouteOptions struct
func (*APIWS) ServeHTTP ¶
func (a *APIWS) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP serves a request passed in w and r, and can be used for integration tests.
func (*APIWS) WithAuthentication ¶
func (a *APIWS) WithAuthentication(b auth.Authentication) *APIWS
WithAuthentication configures the authentication backend to use. Currently implemented authentication are auth.Basic, auth.File and auth.OIDC.
type RouteOptions ¶
type RouteOptions struct {
// Disable logging for this route. Useful for routes that are often called
// as part of the normal behaviour of the application and would pollute the
// logs.
DisableLogging bool
// contains filtered or unexported fields
}
RouteOptions contains optional arguments when adding routes
Directories
¶
| Path | Synopsis |
|---|---|
|
Authentication package provides a set of authentication backends for your application.
|
Authentication package provides a set of authentication backends for your application. |
|
basic
Basic authentication provides a simple username/password authentication passed in authentication header.
|
Basic authentication provides a simple username/password authentication passed in authentication header. |
|
file
File is an authentication that takes users from a yaml file Example :
|
File is an authentication that takes users from a yaml file Example : |
|
oidc
package oidc provides OIDC authentication to APIWS.
|
package oidc provides OIDC authentication to APIWS. |
|
internal
|
|
|
middleware
|
|