Skip to content

Commit

Permalink
Loader hook, ExceptionalResponse constructor, migration guide update
Browse files Browse the repository at this point in the history
  • Loading branch information
essenciary committed Oct 3, 2022
1 parent bcf8810 commit 21a58dd
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Genie"
uuid = "c43c736e-a2d1-11e8-161f-af95117fbd1e"
authors = ["Adrian Salceanu <[email protected]>"]
version = "5.6.2"
version = "5.7.0"

[deps]
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
Expand Down
12 changes: 11 additions & 1 deletion docs/src/guides/Migrating_from_v4_to_v5.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,16 @@ Genie v4 apps would automatically import `Genie` in `Main`, so that `Genie` woul

The scripts responsible for starting the app in non-interactive/serving mode need to be updated by replacing the end of the command from `s "$@"` to `-s=true "$@"`.

### 19. Other
### 19. Update `config/initializers/logging.jl`

Update the content of the `logging.jl` initializer to this:

```julia
import Genie

Genie.Logger.initialize_logging()
```

### 20. Other

Genie 5 also changes or removes other APIs which can be generally be considered as internal. If you find other important breaking changes that have been missed, please open an issue on the Genie GitHub repository or just edit this file and submit a PR.
3 changes: 3 additions & 0 deletions src/Exceptions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ isauthenticated() || throw(ExceptionalResponse(redirect(:show_login)))
struct ExceptionalResponse <: Exception
response::HTTP.Response
end
function ExceptionalResponse(status, headers, body)
HTTP.Response(status, headers, body) |> ExceptionalResponse
end

Base.show(io::IO, ex::ExceptionalResponse) = print(io, "ExceptionalResponseException: $(ex.response.status) - $(Dict(ex.response.headers))")

Expand Down
8 changes: 8 additions & 0 deletions src/Loader.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import REPL, REPL.Terminals
import Revise
import Genie

const post_load_hooks = Function[]

### PRIVATE ###

Expand Down Expand Up @@ -234,6 +235,13 @@ function load(; context::Union{Module,Nothing} = nothing) :: Nothing
Genie.Repl.replprint("$i", t; prefix = "Loading ", clearline = 3, color = :green, sleep_time = 0.1)
end

if ! isempty(post_load_hooks)
Genie.Repl.replprint("Running post load hooks ✅", t; clearline = 3, color = :green, sleep_time = 0.1)
for f in unique(post_load_hooks)
f |> Base.invokelatest
end
end

Genie.Repl.replprint("\nReady! \n", t; clearline = 1, color = :green, bold = :true)
println()

Expand Down

2 comments on commit 21a58dd

@essenciary
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/69456

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v5.7.0 -m "<description of version>" 21a58dd1a8ffff73633ab6d1f8c12a8e950c1b74
git push origin v5.7.0

Please sign in to comment.