Documentation ¶
Index ¶
- Variables
- func RegisterStaticFileProcessor(ending string, processorFunc StaticFileProcessorFunc)
- func RegisterStaticPath(path string, directory string)
- type Application
- func (a *Application) AccessLogHandler(next http.Handler) http.Handler
- func (a *Application) BufferOutputHandler(next http.Handler) http.Handler
- func (a *Application) Init(self ApplicationI)
- func (a *Application) InitializeLoggers()
- func (a *Application) MakeAppServer() http.Handler
- func (a *Application) PutContext(r *http.Request) *http.Request
- func (a *Application) PutContextHandler(next http.Handler) http.Handler
- func (a *Application) ServeApiHandler(next http.Handler) http.Handler
- func (a *Application) ServeApiRequest(w http.ResponseWriter, r *http.Request) bool
- func (a *Application) ServeAppHandler(buf *bytes.Buffer, next http.Handler) http.Handler
- func (a *Application) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (a *Application) ServeRequest(w http.ResponseWriter, r *http.Request)
- func (a *Application) ServeRequestHandler(buf *bytes.Buffer) http.Handler
- func (a *Application) ServeStaticFile(w http.ResponseWriter, r *http.Request) bool
- func (a *Application) ServeStaticFileHandler(buf *bytes.Buffer, next http.Handler) http.Handler
- func (a *Application) SessionHandler(next http.Handler) http.Handler
- func (a *Application) SetupAssetDirectories()
- func (a *Application) SetupDatabaseWatcher()
- func (a *Application) SetupErrorPageTemplate()
- func (a *Application) SetupMessenger()
- func (a *Application) SetupPageCaching()
- func (a *Application) SetupSessionManager()
- type ApplicationI
- type StaticFileProcessorFunc
Constants ¶
This section is empty.
Variables ¶
var StaticBlacklist = []string{".go"}
StaticBlacklist is the list of file terminators that specify what files we always want to hide from view when a static file directory is searched. The default will always hide .go files. Add to it if you have other kinds of files in your static directories that you do not want to show. Do this only at startup.
var StaticDirectoryPaths *maps.StringSliceMap
StaticDirectoryPaths is a map of patterns to directory locations to serve statically. These can be registered at the command line or in the application
Functions ¶
func RegisterStaticFileProcessor ¶ added in v0.0.9
func RegisterStaticFileProcessor(ending string, processorFunc StaticFileProcessorFunc)
func RegisterStaticPath ¶ added in v0.0.9
RegisterStaticPath registers the given url path such that it points to the given directory. For example, passing "/test", "/my/test/dir" will statically serve everything out of /my/test/dir whenever a url has /test in front of it. You can only call this during application startup. These directory paths take precedence over other similar paths that you have registered through goradd forms or through the html directory.
Types ¶
type Application ¶
The application base, to be embedded in your application
func (*Application) AccessLogHandler ¶ added in v0.5.1
func (a *Application) AccessLogHandler(next http.Handler) http.Handler
AccessLogHandler simply logs requests.
func (*Application) BufferOutputHandler ¶ added in v0.0.5
func (a *Application) BufferOutputHandler(next http.Handler) http.Handler
BufferOutputHandler manages the buffering of http output. It must be after any handlers that actually respond to the request.
func (*Application) Init ¶
func (a *Application) Init(self ApplicationI)
func (*Application) InitializeLoggers ¶
func (a *Application) InitializeLoggers()
InitializeLoggers sets up the various types of logs for various types of builds. By default, the DebugLog and FrameworkDebugLogs will be deactivated when the config.Debug variables are false. Otherwise, configure how you want, and simply remove a log if you don't want it to log anything.
func (*Application) MakeAppServer ¶
func (a *Application) MakeAppServer() http.Handler
MakeAppServer creates the handler chain that will handle http requests. There are a ton of ways to do this, 3rd party libraries to help with this, and middlewares you can use. This is a working example, and not a declaration of any "right" way to do this, since it can be very application specific. Generally you must make sure that PutContextHandler is called before ServeAppHandler in the chain.
func (*Application) PutContext ¶
func (a *Application) PutContext(r *http.Request) *http.Request
func (*Application) PutContextHandler ¶
func (a *Application) PutContextHandler(next http.Handler) http.Handler
PutContextHandler is an http handler that adds the application context to the current context.
func (*Application) ServeApiHandler ¶ added in v0.0.9
func (a *Application) ServeApiHandler(next http.Handler) http.Handler
ServeApiHandler serves up an http API. This could be a REST api or something else.
func (*Application) ServeApiRequest ¶ added in v0.0.9
func (a *Application) ServeApiRequest(w http.ResponseWriter, r *http.Request) bool
ServeApiRequest serves up an http api call. The prefix has been removed, so we just process the URL as if it were the command itself. This is currently just a stub to allow you to implement your own API. Eventually we hope this could be an auto-generated REST api or GraphQL api.
func (*Application) ServeAppHandler ¶
ServeAppHandler processes requests for goradd forms
func (*Application) ServeHTTP ¶
func (a *Application) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*Application) ServeRequest ¶
func (a *Application) ServeRequest(w http.ResponseWriter, r *http.Request)
ServeRequest is the place to serve up any files that have not been handled in any other way, either by a previously declared handler, or by the goradd app server. ServeRequest is only called when all the other methods have failed. Override it to handle other files, or to change the messaging when a bad url is attempted.
func (*Application) ServeRequestHandler ¶
func (a *Application) ServeRequestHandler(buf *bytes.Buffer) http.Handler
ServeRequestHandler is the last handler on the default call chain. It calls ServeRequest so the sub-class can handle it.
func (*Application) ServeStaticFile ¶
func (a *Application) ServeStaticFile(w http.ResponseWriter, r *http.Request) bool
ServeStaticFile serves up static html and other files found in registered directories. If the file is not found, it will return false.
func (*Application) ServeStaticFileHandler ¶
ServeStaticFileHandler serves up static files by calling ServeStaticFile.
func (*Application) SessionHandler ¶
func (a *Application) SessionHandler(next http.Handler) http.Handler
SessionHandler initializes the global session handler. This default version uses the scs session handler. Feel free to replace it with the session handler of your choice.
func (*Application) SetupAssetDirectories ¶
func (a *Application) SetupAssetDirectories()
SetupAssetDirectories registers default directories that will contain web assets. These assets are served up in place in development mode, and served from a specified asset directory in release mode. This means the assets will need to be copied to a central location and moved to the release server. See the build directory for info.
func (*Application) SetupDatabaseWatcher ¶ added in v0.3.1
func (a *Application) SetupDatabaseWatcher()
SetupDatabaseWatcher injects the global database watcher and the database broadcaster which together detect database changes and then draws controls that are watching for those
func (*Application) SetupErrorPageTemplate ¶
func (a *Application) SetupErrorPageTemplate()
SetupErrorPageTemplate sets the template that controls the output when an error happens during the processing of a page request, including any code that panics. By default, in debug mode, it will popup an error message in the browser with debug information when an error occurs. And in release mode it will popup a simple message that an error occurred and will log the error to the error log. You can implement this function in your local application object to override it and do something different.
func (*Application) SetupMessenger ¶ added in v0.3.1
func (a *Application) SetupMessenger()
SetupMessenger injects the global messenger that permits pub/sub communication between the server and client
func (*Application) SetupPageCaching ¶
func (a *Application) SetupPageCaching()
SetupPageCaching sets up the service that saves pagestate information that reflects the state of a goradd form to our go code. The default sets up a one server-one process cache that does not scale, which works great for development, testing, and for moderate amounts of traffic. Override and replace the page cache with one that serializes the page state and saves it to a database to make it scalable.
func (*Application) SetupSessionManager ¶
func (a *Application) SetupSessionManager()
SetupSessionManager sets up the session manager. The session can be used to save data that is specific to a user and specific to the user's time on a browser. Sessions are often used to save login credentials so that you know the current user is logged in.
The default uses a 3rd party session manager, and stores the session in memory, which is useful for development, testing, debugging, and for moderately used websites. The default does not scale, so replace it with a different storage mechanism is you are launching multiple copies of the app.
type ApplicationI ¶
type ApplicationI interface { Init() ServeHTTP(w http.ResponseWriter, r *http.Request) PutContext(*http.Request) *http.Request SetupErrorPageTemplate() SetupPageCaching() InitializeLoggers() SetupAssetDirectories() SetupSessionManager() SetupMessenger() SetupDatabaseWatcher() SessionHandler(next http.Handler) http.Handler ServeRequest(w http.ResponseWriter, r *http.Request) ServeStaticFile(w http.ResponseWriter, r *http.Request) bool ServeApiRequest(w http.ResponseWriter, r *http.Request) bool AccessLogHandler(next http.Handler) http.Handler }
The application interface. A minimal set of commands that the main routine will ask the application to do. The main routine offers a way of creating mock applications, and alternate versions of the application from the default
type StaticFileProcessorFunc ¶ added in v0.0.9
type StaticFileProcessorFunc func(file string, w http.ResponseWriter, r *http.Request)