Genie.serveFunction
serve(path::String = pwd(), params...; kwparams...)

Serves a folder of static files located at path. Allows Genie to be used as a static files web server. The params and kwparams arguments are forwarded to Genie.startup().

Arguments

  • path::String: the folder of static files to be served by the server
  • params: additional arguments which are passed to Genie.startup to control the web server
  • kwparams: additional keyword arguments which are passed to Genie.startup to control the web server

Examples

julia> Genie.serve("public", 8888, async = false, verbose = true)
[ Info: Ready!
2019-08-06 16:39:20:DEBUG:Main: Web Server starting at http://127.0.0.1:8888
[ Info: Listening on: 127.0.0.1:8888
[ Info: Accept (1):  🔗    0↑     0↓    1s 127.0.0.1:8888:8888 ≣16
source
Genie.newappFunction
newapp(path::String = "."; autostart::Bool = true, fullstack::Bool = false, dbsupport::Bool = false, mvcsupport::Bool = false) :: Nothing

Scaffolds a new Genie app, setting up the file structure indicated by the various arguments.

Arguments

  • path::String: the name of the app and the path where to bootstrap it
  • autostart::Bool: automatically start the app once the file structure is created
  • fullstack::Bool: the type of app to be bootstrapped. The fullstack app includes MVC structure, DB connection code, and asset pipeline files.
  • dbsupport::Bool: bootstrap the files needed for DB connection setup via the SearchLight ORM
  • mvcsupport::Bool: adds the files used for HTML+Julia view templates rendering and working with resources

Examples

julia> Genie.newapp("MyGenieApp")
2019-08-06 16:54:15:INFO:Main: Done! New app created at MyGenieApp
2019-08-06 16:54:15:DEBUG:Main: Changing active directory to MyGenieApp
2019-08-06 16:54:15:DEBUG:Main: Installing app dependencies
 Resolving package versions...
  Updating `~/Dropbox/Projects/GenieTests/MyGenieApp/Project.toml`
  [c43c736e] + Genie v0.10.1
  Updating `~/Dropbox/Projects/GenieTests/MyGenieApp/Manifest.toml`

2019-08-06 16:54:27:INFO:Main: Starting your brand new Genie app - hang tight!
 _____         _
|   __|___ ___|_|___
|  |  | -_|   | | -_|
|_____|___|_|_|_|___|

┌ Info:
│ Starting Genie in >> DEV << mode
└
[ Info: Logging to file at MyGenieApp/log/dev.log
[ Info: Ready!
2019-08-06 16:54:32:DEBUG:Main: Web Server starting at http://127.0.0.1:8000
2019-08-06 16:54:32:DEBUG:Main: Web Server running at http://127.0.0.1:8000
source
Genie.newapp_webserviceFunction
newapp_webservice(path::String = "."; autostart::Bool = true, dbsupport::Bool = false) :: Nothing

Template for scaffolding a new Genie app suitable for nimble web services.

Arguments

  • path::String: the name of the app and the path where to bootstrap it
  • autostart::Bool: automatically start the app once the file structure is created
  • dbsupport::Bool: bootstrap the files needed for DB connection setup via the SearchLight ORM
  • dbadapter::Union{String,Symbol,Nothing} = nothing : pass the SearchLight database adapter to be used by default

(one of :MySQL, :SQLite, or :PostgreSQL). If dbadapter is nothing, an adapter will have to be selected interactivel at the REPL, during the app creation process.

source
Genie.newapp_mvcFunction
newapp_mvc(path::String = "."; autostart::Bool = true) :: Nothing

Template for scaffolding a new Genie app suitable for MVC web applications (includes MVC structure and DB support).

Arguments

  • path::String: the name of the app and the path where to bootstrap it
  • autostart::Bool: automatically start the app once the file structure is created
  • dbadapter::Union{String,Symbol,Nothing} = nothing : pass the SearchLight database adapter to be used by default

(one of :MySQL, :SQLite, or :PostgreSQL). If dbadapter is nothing, an adapter will have to be selected interactivel at the REPL, during the app creation process.

source
Genie.newapp_fullstackFunction
newapp_fullstack(path::String = "."; autostart::Bool = true) :: Nothing

Template for scaffolding a new Genie app suitable for full stack web applications (includes MVC structure, DB support, and frontend asset pipeline).

Arguments

  • path::String: the name of the app and the path where to bootstrap it
  • autostart::Bool: automatically start the app once the file structure is created
  • dbadapter::Union{String,Symbol,Nothing} = nothing : pass the SearchLight database adapter to be used by default

(one of :MySQL, :SQLite, or :PostgreSQL). If dbadapter is nothing, an adapter will have to be selected interactivel at the REPL, during the app creation process.

source
Genie.loadappFunction
loadapp(path::String = "."; autostart::Bool = false) :: Nothing

Loads an existing Genie app from the file system, within the current Julia REPL session.

Arguments

  • path::String: the path to the Genie app on the file system.
  • autostart::Bool: automatically start the app upon loading it.

Examples

shell> tree -L 1
.
├── Manifest.toml
├── Project.toml
├── bin
├── bootstrap.jl
├── config
├── env.jl
├── genie.jl
├── log
├── public
├── routes.jl
└── src

5 directories, 6 files

julia> using Genie

julia> Genie.loadapp(".")
 _____         _
|   __|___ ___|_|___
|  |  | -_|   | | -_|
|_____|___|_|_|_|___|

┌ Info:
│ Starting Genie in >> DEV << mode
└
[ Info: Logging to file at MyGenieApp/log/dev.log
source
Genie.startupFunction
startup(port::Int = Genie.config.server_port, host::String = Genie.config.server_host;
    ws_port::Int = Genie.config.websockets_port, async::Bool = ! Genie.config.run_as_server) :: Nothing

Starts the web server. Alias for AppServer.startup

Arguments

  • port::Int: the port used by the web server
  • host::String: the host used by the web server
  • ws_port::Int: the port used by the Web Sockets server
  • async::Bool: run the web server task asynchronously

Examples

julia> startup(8000, "127.0.0.1", async = false)
[ Info: Ready!
Web Server starting at http://127.0.0.1:8000
source
Genie.upFunction
startup(port::Int = Genie.config.server_port, host::String = Genie.config.server_host;
    ws_port::Int = Genie.config.websockets_port, async::Bool = ! Genie.config.run_as_server) :: ServersCollection

Starts the web server.

Arguments

  • port::Int: the port used by the web server
  • host::String: the host used by the web server
  • ws_port::Int: the port used by the Web Sockets server
  • async::Bool: run the web server task asynchronously

Examples

julia> up(8000, "127.0.0.1", async = false)
[ Info: Ready!
Web Server starting at http://127.0.0.1:8000
source
Genie.downFunction
down(; webserver::Bool = true, websockets::Bool = true) :: ServersCollection

Shuts down the servers optionally indicating which of the webserver and websockets servers to be stopped. It does not remove the servers from the SERVERS collection. Returns the collection.

source
Genie.runFunction
run() :: Nothing

Runs the Genie app by parsing the command line args and invoking the corresponding actions. Used internally to parse command line arguments.

source
Genie.newcontrollerFunction
newcontroller(controller_name::Union{String,Symbol}) :: Nothing

Creates a new controller file. If pluralize is false, the name of the controller is not automatically pluralized.

source
Genie.newresourceFunction
newresource(resource_name::Union{String,Symbol}; pluralize::Bool = true, context::Union{Module,Nothing} = nothing) :: Nothing

Creates all the files associated with a new resource. If pluralize is false, the name of the resource is not automatically pluralized.

source
Genie.newtaskFunction
newtask(task_name::Union{String,Symbol}) :: Nothing

Creates a new Genie Task file.

source
Genie.load_libsFunction
load_libs(root_dir::String = Genie.config.path_lib) :: Nothing

Recursively adds subfolders of lib/ to LOAD_PATH. The lib/ folder, if present, is designed to host user code in the form of .jl files. This function loads user code into the Genie app.

source
Genie.load_resourcesFunction
load_resources(root_dir::String = Genie.config.path_resources) :: Nothing

Recursively adds subfolders of resources/ to LOAD_PATH.

source
Genie.load_helpersFunction
load_helpers(root_dir::String = Genie.config.path_helpers) :: Nothing

Recursively adds subfolders of helpers/ to LOAD_PATH.

source
Genie.load_configurationsFunction
load_configurations(root_dir::String = Genie.config.path_config; context::Union{Module,Nothing} = nothing) :: Nothing

Loads (includes) the framework's configuration files into the app's module context. The files are set up with Revise to be automatically reloaded.

source
Genie.load_initializersFunction
load_initializers(root_dir::String = Genie.config.path_config; context::Union{Module,Nothing} = nothing) :: Nothing

Loads (includes) the framework's initializers. The files are set up with Revise to be automatically reloaded.

source
Genie.load_pluginsFunction
load_plugins(root_dir::String = Genie.config.path_plugins; context::Union{Module,Nothing} = nothing) :: Nothing

Loads (includes) the framework's plugins initializers.

source
Genie.load_routes_definitionsFunction
load_routes_definitions(routes_file::String = Genie.ROUTES_FILE_NAME; context::Union{Module,Nothing} = nothing) :: Nothing

Loads the routes file.

source
Genie.secret_tokenFunction
secret_token(generate_if_missing=true) :: String

Return the secret token used in the app for encryption and salting.

Usually, this token is defined through Genie.secret_token! in the config/secrets.jl file. Here, a temporary one is generated for the current session if no other token is defined and generate_if_missing is true.

source
Genie.default_contextFunction
default_context(context::Union{Module,Nothing})

Sets the module in which the code is loaded (the app's module)

source
Genie.loadFunction
load(; context::Union{Module,Nothing} = nothing) :: Nothing

Main entry point to loading a Genie app.

source
Genie.replprintFunction
replprint(output::String, terminal;
                newline::Int = 0, clearline::Int = 1, color::Symbol = :white, bold::Bool = false, sleep_time::Float64 = 0.2,
                prefix::String = "", prefix_color::Symbol = :green, prefix_bold::Bool = true)

Prints app loading progress to the console.

source