4

Hunchentootを使用していますが、セッションCookieの名前を変更したいと思います。これはジェネリック関数で実装されており、ドキュメントには「関数を特殊化する」ことができる名前を変更するように書かれています。

ここでこれが何を意味するのかよくわかりません。関数に特化するのは、特定の引数タイプにメソッドをディスパッチすることだという印象を受けました。この特定のケースでは、関数はサーバーアクセプターを取得しますが、これは変更したくありません。誰かがこれについて私を照らすことができますか?

API:http ://weitz.de/hunchentoot/#session-cookie-name

ソースの実装は次のとおりです。

 (defgeneric session-cookie-name (acceptor)                                          
    (:documentation "Returns the name \(a string) of the cookie \(or the              
    GET parameter) which is used to store a session on the client side.                 
    The default is to use the string \"hunchentoot-session\", but you can               
    specialize this function if you want another name."))                               

 (defmethod session-cookie-name ((acceptor t))
    "hunchentoot-session")
4

1 に答える 1

3

サブクラスを作成し、そのように専門化します。

(defclass my-acceptor (hunchentoot:acceptor) ())

(defmethod session-cookie-name ((acceptor my-acceptor)) 
  "my-session")

関数はまだアクセプターを取ります、それは今あなたの種類のアクセプターです。

于 2010-01-21T10:53:22.897 に答える