Writer
Writer is used to write content into Response:
Compared to Handler:
The main differences between them are:
- Different purposes:
Writerrepresents writing specific content intoResponse, implemented by concrete content such as strings, error messages, etc. In contrast,Handleris used to process the entire request. Writeris created within aHandlerand consumes itself when thewritefunction is called, making it a one-time call. On the other hand,Handleris shared across all requests.Writercan be returned as the content in theResultof aHandler.Writerdoes not include aFlowCtrlparameter, so it cannot control the execution flow of the entire request.
Scribe implements Writer but offers fewer capabilities compared to Writer:
The rendering function of Scribe only writes data into Response and cannot retrieve information from Request or Depot during this process.