Kap5 Server Go Flashcards
Was macht ein Multiplexer in general?
Dispatches/Routes incoming requests and maps URL to controller
Was macht ein Multiplexer in Go?
ServerMux is a struct thats maps a URL to a handler and DefaultServerMux is an instance of ServerMux
ServerMux exact match?
for any URL that does not end with a slash
ServerMux closest match?
for any URL pattern that ends with a
slash
Was macht ein Handler in general?
Controller process requests, are invoked by multiplexer/dispatcher and contain application logic
Was macht ein Handler in Go?
Controllers are handlers and they are interfaces that have a method named ServeHTTP with two parameters
What is important about templates?
Templates are a predesigned HTML page or fragment. The template engine combines data with template and contains embedded logic for data processing. Handlers usually call template engine to obtain resultant HTML
How are templates executed?
Templates are executed within handler and are usually the last statement of handler
Was macht ein Model in general?
Model defines application-related data, uniform access and management of data and Models are independent from storage strategy or technology
Why are Sessions important?
Modern web applications demand preserving the status of users over the duration of multiple requests
To preserve the status of users over the
duration of multiple requests…?
…each request needs to be linkable to one particular
user
…each request needs to carry user identifiable
information (aka session ID or user ID)
…user-specific session information needs to be
stored at server-side or encrypted on the client-side
What are the 2 technics to add user identifiable information to each request?
URL rewriting and Cookies
What are the cons of URL rewriting?
Each URL is extended by unique ID in query string, so the URLs contain sensitive information. Needs to be implemented on server-side and is not very commonly used anymore
Was are the benefits of Cookies?
Generated and assigned to particular used by server, Browser stores and manages cookies domain-wise. Adds valid cookie to each request for which cookie exists
What is important in Session management design?
Global session manager, keep session id unique, have one session for every user, session storage in memory, file or database