Skip to content

Commit

Permalink
feat: bring back client.Hijack method that was previously removed.
Browse files Browse the repository at this point in the history
  • Loading branch information
amatsagu committed Feb 6, 2024
1 parent a51c916 commit 7b086f2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,16 @@ func (client *Client) ListenAndServeTLS(route string, address string, certFile,
return nil
}

// Let's you take control over client's life cycle. Please avoid using it unless you want to integrate custom http client.
func (client *Client) Hijack() (func(w http.ResponseWriter, r *http.Request), error) {
if client.State() != INIT_STATE {
return nil, errors.New("client is no longer in initialization state")
}

client.state.Store(uint32(RUNNING_STATE))
return client.handleRequest, nil
}

// Tries to gracefully shutdown client. It'll clear all queued actions and shutdown underlying http server.
func (client *Client) Close(ctx context.Context) error {
if client.State() == INIT_STATE {
Expand Down

0 comments on commit 7b086f2

Please sign in to comment.