Skip to content

Commit

Permalink
v0.26.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian committed Feb 11, 2020
2 parents 49a4d49 + 0b77bd7 commit b5cf05a
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 21 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: TagBot
on:
schedule:
- cron: 0 * * * *
jobs:
TagBot:
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions docs/documentation/17--Working_with_Web_Sockets.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ We are ready to interact with the client. Go to the Julia REPL running the web a
```julia
julia> Genie.WebChannels.connected_clients()
1-element Array{Genie.WebChannels.ChannelClient,1}:
Genie.WebChannels.ChannelClient(HTTP.WebSockets.WebSocket{HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}(T0 🔁 0🔒 0🔒 100s 0.0.0.0:8001:8001 16, 0x01, true, UInt8[0x7b, 0x22, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x22 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x3a, 0x7b, 0x7d, 0x7d], UInt8[], false, false), ["__"])
Genie.WebChannels.ChannelClient(HTTP.WebSockets.WebSocket{HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}(T0 🔁 0🔒 0🔒 100s 127.0.0.1:8001:8001 16, 0x01, true, UInt8[0x7b, 0x22, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x22 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x3a, 0x7b, 0x7d, 0x7d], UInt8[], false, false), ["__"])
```

We have one connected client to the `__` channel! We can send it a message:
Expand Down Expand Up @@ -151,4 +151,4 @@ Got this payload: Received: Hello!

## Summary

This concludes our intro to working with WebSockets in Genie. You know have the knowledge to set up the communication between client and server, send messages from both server and clients, and perform various tasks using the `WebChannels` API.
This concludes our intro to working with WebSockets in Genie. You know have the knowledge to set up the communication between client and server, send messages from both server and clients, and perform various tasks using the `WebChannels` API.
6 changes: 3 additions & 3 deletions docs/guides/Working_With_Genie_Apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Upon executing the command, Genie will:
* create a new Julia project (adding the `Project.toml` and `Manifest.toml` files),
* activate the project,
* automatically load the new app's environment into the REPL,
* start the web server on the default Genie port (port 8000) and host (0.0.0.0).
* start the web server on the default Genie port (port 8000) and host (127.0.0.1).

At this point you can confirm that everything worked as expected by visiting <http://0.0.0.0:8000> in your favourite web browser. You should see Genie's welcome page.
At this point you can confirm that everything worked as expected by visiting <http://127.0.0.1:8000> in your favourite web browser. You should see Genie's welcome page.

Next, let's add a new route. Routes are used to map request URLs to Julia functions. These functions provide the response that will be sent back to the client. Routes are meant to be defined in the dedicated `routes.jl` file. Open `MyGenieApp/routes.jl` in your editor or run the following command (making sure that you are in the app's directory):

Expand All @@ -38,7 +38,7 @@ end

We are using the `route` method, passing in the "/hello" URL and an anonymous function which returns the string "Welcome to Genie!". What this means is that for each request to the "/hello" URL, our app will invoke the route handler function and respond with the welcome message.

Visit <http://0.0.0.0:8000/hello> for a warm welcome!
Visit <http://127.0.0.1:8000/hello> for a warm welcome!

## Working with resources

Expand Down
2 changes: 1 addition & 1 deletion files/new_app/config/env/dev.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ using Genie.Configuration, Logging

const config = Settings(
server_port = 8000,
server_host = "0.0.0.0",
server_host = "127.0.0.1",
log_level = Logging.Debug,
log_to_file = false,
server_handle_static_files = true
Expand Down
2 changes: 1 addition & 1 deletion files/new_app/config/env/test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ using Genie.Configuration, Logging

const config = Settings(
server_port = 8000,
server_host = "0.0.0.0",
server_host = "127.0.0.1",
log_level = Logging.Debug,
log_to_file = true,
server_handle_static_files = true
Expand Down
7 changes: 5 additions & 2 deletions files/new_app/genie.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using Revise

haskey(ENV, "HOST") || (ENV["HOST"] = "0.0.0.0")
haskey(ENV, "GENIE_ENV") || (ENV["GENIE_ENV"] = "dev")
if !haskey(ENV, "HOST")
ENV["HOST"] = (ENV["GENIE_ENV"] == "dev") ? "127.0.0.1" : "0.0.0.0"
end


### EARLY BIND TO PORT FOR HOSTS WITH TIMEOUT ###

Expand Down Expand Up @@ -31,4 +34,4 @@ const ROOT_PATH = pwd()
push!(LOAD_PATH, ROOT_PATH, "src")

Genie.load(context = @__MODULE__)
Genie.run(server = EARLYBINDING)
Genie.run(server = EARLYBINDING)
4 changes: 2 additions & 2 deletions src/AppServer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ Starts the web server.
# Examples
```julia-repl
julia> startup(8000, "0.0.0.0", async = false)
julia> startup(8000, "127.0.0.1", async = false)
[ Info: Ready!
Web Server starting at http://0.0.0.0:8000
Web Server starting at http://127.0.0.1:8000
```
"""
function startup(port::Int = Genie.config.server_port, host::String = Genie.config.server_host;
Expand Down
4 changes: 2 additions & 2 deletions src/Configuration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const TEST = "test"


haskey(ENV, "GENIE_ENV") || (ENV["GENIE_ENV"] = DEV)
haskey(ENV, "HOST") || (ENV["HOST"] = "0.0.0.0")
haskey(ENV, "HOST") || (ENV["HOST"] = "127.0.0.1")


"""
Expand Down Expand Up @@ -96,7 +96,7 @@ App configuration - sets up the app's defaults. Individual options are overwritt
# Arguments
- `server_port::Int`: the port for running the web server (default 8000)
- `server_host::String`: the host for running the web server (default "0.0.0.0")
- `server_host::String`: the host for running the web server (default "127.0.0.1")
- `server_document_root::String`: path to the document root (default "public/")
- `server_handle_static_files::Bool`: if `true`, Genie will also serve static files. In production, it is recommended to serve static files with a web server like Nginx.
- `server_signature::String`: Genie's signature used for tagging the HTTP responses. If empty, it will not be added.
Expand Down
2 changes: 1 addition & 1 deletion src/Deploy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,4 @@ end

end # end module Heroku

end # end module Deploy
end # end module Deploy
4 changes: 2 additions & 2 deletions src/Genie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ Starts the web server. Alias for `AppServer.startup`
# Examples
```julia-repl
julia> startup(8000, "0.0.0.0", async = false)
julia> startup(8000, "127.0.0.1", async = false)
[ Info: Ready!
Web Server starting at http://0.0.0.0:8000
Web Server starting at http://127.0.0.1:8000
```
"""
const startup = AppServer.startup
Expand Down
2 changes: 1 addition & 1 deletion src/Router.jl
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ function match_channels(req, msg::String, ws_client, params::Params) :: String

result
catch ex
isa(ex, Exception) ? ex.msg : rethrow(ex)
isa(ex, Exception) ? sprint(showerror, ex) : rethrow(ex)
end
end

Expand Down
8 changes: 4 additions & 4 deletions test/tests_config.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
using Genie

@test Genie.config.server_port == 8000
@test Genie.config.server_host == "0.0.0.0"
@test Genie.config.server_host == "127.0.0.1"
@test Genie.config.websockets_port == 8001
@test Genie.config.run_as_server == false

up(9000, "127.0.0.1", ws_port = 9999)
up(9000, "0.0.0.0", ws_port = 9999)

@test Genie.config.server_port == 9000
@test Genie.config.server_host == "127.0.0.1"
@test Genie.config.server_host == "0.0.0.0"
@test Genie.config.websockets_port == 9999
@test Genie.config.run_as_server == false
end;
end;
end;

0 comments on commit b5cf05a

Please sign in to comment.